diff --git a/L2J_Mobius_1.0_Ertheia/.classpath b/L2J_Mobius_1.0_Ertheia/.classpath
index ced70bc3b1..96404c8fee 100644
--- a/L2J_Mobius_1.0_Ertheia/.classpath
+++ b/L2J_Mobius_1.0_Ertheia/.classpath
@@ -5,11 +5,13 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_1.0_Ertheia/build.xml b/L2J_Mobius_1.0_Ertheia/build.xml
index e65e75754f..d45b0d7777 100644
--- a/L2J_Mobius_1.0_Ertheia/build.xml
+++ b/L2J_Mobius_1.0_Ertheia/build.xml
@@ -30,6 +30,7 @@
+
@@ -135,7 +136,7 @@
-
+
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.50.Final.jar
similarity index 52%
rename from L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.38.Final.jar
rename to L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.50.Final.jar
index 1ec34bd6f3..f8b1557478 100644
Binary files a/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.38.Final.jar and b/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.30.jar
similarity index 54%
rename from L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.27.jar
rename to L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.30.jar
index f74802295a..29ac26fb8c 100644
Binary files a/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.27.jar and b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.30.jar
similarity index 79%
rename from L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.27.jar
rename to L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.30.jar
index 17f96a8f1c..6debaa9dec 100644
Binary files a/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.27.jar and b/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_2.5_Underground/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_2.5_Underground/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.50.Final.jar
similarity index 52%
rename from L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.38.Final.jar
rename to L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.50.Final.jar
index 1ec34bd6f3..f8b1557478 100644
Binary files a/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.38.Final.jar and b/L2J_Mobius_2.5_Underground/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.30.jar
similarity index 54%
rename from L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.27.jar
rename to L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.30.jar
index f74802295a..29ac26fb8c 100644
Binary files a/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.27.jar and b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.30.jar
similarity index 79%
rename from L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.27.jar
rename to L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.30.jar
index 17f96a8f1c..6debaa9dec 100644
Binary files a/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.27.jar and b/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_3.0_Helios/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_3.0_Helios/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.50.Final.jar
similarity index 52%
rename from L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.38.Final.jar
rename to L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.50.Final.jar
index 1ec34bd6f3..f8b1557478 100644
Binary files a/L2J_Mobius_1.0_Ertheia/dist/libs/netty-all-4.1.38.Final.jar and b/L2J_Mobius_3.0_Helios/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.30.jar
similarity index 54%
rename from L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.27.jar
rename to L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.30.jar
index f74802295a..29ac26fb8c 100644
Binary files a/L2J_Mobius_2.5_Underground/dist/libs/slf4j-api-1.7.27.jar and b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.30.jar
similarity index 79%
rename from L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.27.jar
rename to L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.30.jar
index 17f96a8f1c..6debaa9dec 100644
Binary files a/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.27.jar and b/L2J_Mobius_3.0_Helios/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.50.Final.jar
similarity index 52%
rename from L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.38.Final.jar
rename to L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.50.Final.jar
index 1ec34bd6f3..f8b1557478 100644
Binary files a/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.38.Final.jar and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.30.jar
similarity index 54%
rename from L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.27.jar
rename to L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.30.jar
index f74802295a..29ac26fb8c 100644
Binary files a/L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.27.jar and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.30.jar
similarity index 79%
rename from L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.27.jar
rename to L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.30.jar
index 17f96a8f1c..6debaa9dec 100644
Binary files a/L2J_Mobius_2.5_Underground/dist/libs/slf4j-simple-1.7.27.jar and b/L2J_Mobius_4.0_GrandCrusade/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 9078aa5dcb..462890bdc4 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_5.0_Salvation/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_5.0_Salvation/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_5.0_Salvation/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_5.5_EtinasFate/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_6.0_Fafurion/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_7.0_PreludeOfWar/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_C4_ScionsOfDestiny/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_C6_Interlude/.classpath b/L2J_Mobius_C6_Interlude/.classpath
index 23008d1ee2..7776d4ad45 100644
--- a/L2J_Mobius_C6_Interlude/.classpath
+++ b/L2J_Mobius_C6_Interlude/.classpath
@@ -5,10 +5,10 @@
-
-
-
-
+
+
+
+
diff --git a/L2J_Mobius_C6_Interlude/build.xml b/L2J_Mobius_C6_Interlude/build.xml
index bb04197d34..2016fa66bc 100644
--- a/L2J_Mobius_C6_Interlude/build.xml
+++ b/L2J_Mobius_C6_Interlude/build.xml
@@ -30,6 +30,7 @@
+
@@ -135,7 +136,7 @@
-
+
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_C6_Interlude/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/.classpath b/L2J_Mobius_CT_2.4_Epilogue/.classpath
index ced70bc3b1..568d19f654 100644
--- a/L2J_Mobius_CT_2.4_Epilogue/.classpath
+++ b/L2J_Mobius_CT_2.4_Epilogue/.classpath
@@ -5,11 +5,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/L2J_Mobius_CT_2.4_Epilogue/build.xml b/L2J_Mobius_CT_2.4_Epilogue/build.xml
index 7778e3952f..25a8c48531 100644
--- a/L2J_Mobius_CT_2.4_Epilogue/build.xml
+++ b/L2J_Mobius_CT_2.4_Epilogue/build.xml
@@ -30,6 +30,7 @@
+
@@ -135,7 +136,7 @@
-
+
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_CT_2.4_Epilogue/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/.classpath b/L2J_Mobius_CT_2.6_HighFive/.classpath
index ced70bc3b1..568d19f654 100644
--- a/L2J_Mobius_CT_2.6_HighFive/.classpath
+++ b/L2J_Mobius_CT_2.6_HighFive/.classpath
@@ -5,11 +5,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/L2J_Mobius_CT_2.6_HighFive/build.xml b/L2J_Mobius_CT_2.6_HighFive/build.xml
index 26063f12ba..9493d9c444 100644
--- a/L2J_Mobius_CT_2.6_HighFive/build.xml
+++ b/L2J_Mobius_CT_2.6_HighFive/build.xml
@@ -30,6 +30,7 @@
+
@@ -135,7 +136,7 @@
-
+
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_CT_2.6_HighFive/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/.classpath b/L2J_Mobius_Classic_2.0_Saviors/.classpath
index ced70bc3b1..96404c8fee 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/.classpath
+++ b/L2J_Mobius_Classic_2.0_Saviors/.classpath
@@ -5,11 +5,13 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_Classic_2.0_Saviors/build.xml b/L2J_Mobius_Classic_2.0_Saviors/build.xml
index 95f0f4f8b6..34d564a468 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/build.xml
+++ b/L2J_Mobius_Classic_2.0_Saviors/build.xml
@@ -30,6 +30,7 @@
+
@@ -135,7 +136,7 @@
-
+
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_2.0_Saviors/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_2.1_Zaken/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 9078aa5dcb..462890bdc4 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_2.2_Antharas/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 9078aa5dcb..462890bdc4 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_2.3_SevenSigns/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 9078aa5dcb..462890bdc4 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 6bd8ae2d94..fa70cd9b72 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_3.0_TheKamael/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 6bd8ae2d94..fa70cd9b72 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List
-
+
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.3.1.jar b/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.3.1.jar
deleted file mode 100644
index 476e0c0b7a..0000000000
Binary files a/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.3.1.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.4.5-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.4.5-sources.jar
new file mode 100644
index 0000000000..ea4b7b6a4a
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.4.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.4.5.jar b/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.4.5.jar
new file mode 100644
index 0000000000..95247be0c4
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/HikariCP-3.4.5.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/cron4j-2.2.5-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/cron4j-2.2.5-sources.jar
new file mode 100644
index 0000000000..6eab310e6e
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/cron4j-2.2.5-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/cron4j-2.2.5.jar b/L2J_Mobius_Classic_Interlude/dist/libs/cron4j-2.2.5.jar
new file mode 100644
index 0000000000..53ee2ccf49
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/cron4j-2.2.5.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/exp4j-0.4.8-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/exp4j-0.4.8-sources.jar
new file mode 100644
index 0000000000..f9074f4e4f
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/exp4j-0.4.8-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/exp4j-0.4.8.jar b/L2J_Mobius_Classic_Interlude/dist/libs/exp4j-0.4.8.jar
new file mode 100644
index 0000000000..dd26421402
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/exp4j-0.4.8.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.4.3.jar b/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.4.3.jar
deleted file mode 100644
index cef4ab119e..0000000000
Binary files a/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.4.3.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.6.1-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.6.1-sources.jar
new file mode 100644
index 0000000000..727328c651
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.6.1-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.6.1.jar b/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.6.1.jar
new file mode 100644
index 0000000000..4fa347d1c4
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/mariadb-java-client-2.6.1.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.38.Final.jar b/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.38.Final.jar
deleted file mode 100644
index 1ec34bd6f3..0000000000
Binary files a/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.38.Final.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.50.Final-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.50.Final-sources.jar
new file mode 100644
index 0000000000..d40b0f6ac9
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.50.Final-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.50.Final.jar b/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.50.Final.jar
new file mode 100644
index 0000000000..f8b1557478
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/netty-all-4.1.50.Final.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.27.jar b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.27.jar
deleted file mode 100644
index f74802295a..0000000000
Binary files a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.30-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.30-sources.jar
new file mode 100644
index 0000000000..a282ebb47a
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.30.jar b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000000..29ac26fb8c
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-api-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.27.jar b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.27.jar
deleted file mode 100644
index 17f96a8f1c..0000000000
Binary files a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.27.jar and /dev/null differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.30-sources.jar b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.30-sources.jar
new file mode 100644
index 0000000000..74e77ba026
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.30-sources.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.30.jar b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.30.jar
new file mode 100644
index 0000000000..6debaa9dec
Binary files /dev/null and b/L2J_Mobius_Classic_Interlude/dist/libs/slf4j-simple-1.7.30.jar differ
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
index 4b08765663..9d63a90863 100644
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
+++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/impl/SkillData.java
@@ -47,7 +47,8 @@ import org.l2jmobius.gameserver.model.skills.EffectScope;
import org.l2jmobius.gameserver.model.skills.ISkillCondition;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillConditionScope;
-import org.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
+
+import net.objecthunter.exp4j.ExpressionBuilder;
/**
* Skill data parser.
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
index f599aee66e..f150ec3238 100644
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
+++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/eventengine/EventScheduler.java
@@ -29,8 +29,9 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.StatSet;
-import org.l2jmobius.gameserver.util.cron4j.PastPredictor;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.PastPredictor;
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author UnAfraid
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
index 9078aa5dcb..462890bdc4 100644
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
+++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/dailymission/ExOneDayReceiveRewardList.java
@@ -27,7 +27,8 @@ import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.util.cron4j.Predictor;
+
+import it.sauronsoftware.cron4j.Predictor;
/**
* @author Sdw
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
deleted file mode 100644
index 0ca1d21f63..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/AlwaysTrueValueMatcher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * This ValueMatcher always returns true!
- * @author Carlo Pelliccia
- */
-class AlwaysTrueValueMatcher implements ValueMatcher
-{
- /**
- * Always true!
- */
- @Override
- public boolean match(int value)
- {
- return true;
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
deleted file mode 100644
index 3d2c436dcf..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/CronParser.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A parser for crontab-like formatted files and streams.
- *
- *
- * If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the {@link Scheduler#scheduleFile(File)} method.
- *
- *
- * Consider to use the CronParser if the {@link Scheduler#scheduleFile(File)} method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a {@link File} object (a document on a remote server, a DBMS result set and so on). To solve
- * the problem you can implement your own {@link TaskCollector}, getting the advantage of the CronParser to parse easily any crontab-like content.
- *
- *
- * You can parse a whole file/stream, but you can also parse a single line.
- *
- *
- * A line can be empty, can contain a comment or it can be a scheduling line.
- *
- *
- * A line containing no characters or a line with only space characters is considered an empty line.
- *
- *
- * A line whose first non-space character is a number sign (#) is considered a comment.
- *
- *
- * Empty lines and comment lines are ignored by the parser.
- *
- *
- * Any other kind of line is parsed as a scheduling line.
- *
- *
- * A valid scheduling line respects the following structure:
- *
scheduling-pattern is a valid scheduling pattern, according with the definition given by the {@link SchedulingPattern} class.
- *
options is a list of optional informations used by cron4j to prepare the task execution environment. See below for a more detailed description.
- *
command is a system valid command, such an executable call.
- *
args is a list of optional arguments for the command.
- *
- *
- * After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
- *
- *
- * Double quotation marks delimited items can take advantage of the following escape sequences:
- *
- *
- *
\" - quotation mark
- *
\\ - back slash
- *
\/ - slash
- *
\b - back space
- *
\f - form feed
- *
\n - new line
- *
\r - carriage return
- *
\t - horizontal tab
- *
\u005c\u0075four-hex-digits - the character at the given unicode index
- *
- *
- * The options token collection can include one or more of the following elements:
- *
- *
- *
IN:file-path - Redirects the command standard input channel to the specified file.
- *
OUT:file-path - Redirects the command standard output channel to the specified file.
- *
ERR:file-path - Redirects the command standard error channel to the specified file.
- *
ENV:name=value - Defines an environment variable in the scope of the command.
- *
DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
- *
- *
- * It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
- *
- * The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
- *
- *
- * Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
- *
- *
- * Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is printed in the application standard error channel.
- *
- * Builds a task list reading it from a file.
- *
- *
- * The file is treated as UTF-8. If your source file is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source file are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an URL.
- *
- *
- * Contents fetched from the URL are treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the retrieved document are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * Builds a task list reading it from an input stream.
- *
- *
- * The stream is treated as UTF-8. If your source is not UTF-8 encoded establish by yourself a {@link Reader} using the right charset and pass it to the {@link CronParser#parse(Reader)} method.
- *
- *
- * Syntax and semantics errors in the source stream are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param stream The input stream.
- * @return The task table parsed from the stream contents.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(InputStream stream) throws IOException
- {
- return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- /**
- *
- * Builds a task list reading it from a reader.
- *
- *
- * Syntax and semantics errors in the source reader are not blocking. Invalid lines are discarded, and they cause just a stack trace to be printed in the standard error channel as a notification.
- *
- * @param reader The reader.
- * @return The task table parsed from the contents in the reader.
- * @throws IOException I/O error.
- */
- public static TaskTable parse(Reader reader) throws IOException
- {
- final TaskTable table = new TaskTable();
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
- {
- try
- {
- parseLine(table, line);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- finally
- {
- reader.close();
- }
- return table;
- }
-
- /**
- * Parses a crontab-like line.
- * @param table The table on which the parsed task will be stored, by side-effect.
- * @param lineValue The crontab-like line.
- * @throws Exception The supplied line doesn't represent a valid task line.
- */
- public static void parseLine(TaskTable table, String lineValue) throws Exception
- {
- String line = lineValue.trim();
- if ((line.isEmpty()) || (line.charAt(0) == '#'))
- {
- return;
- }
-
- // Detecting the pattern.
- int size = line.length();
- String pattern = null;
- for (int i = size; i >= 0; i--)
- {
- final String aux = line.substring(0, i);
- if (SchedulingPattern.validate(aux))
- {
- pattern = aux;
- break;
- }
- }
- if (pattern == null)
- {
- throw new Exception("Invalid cron line: " + line);
- }
-
- line = line.substring(pattern.length());
- size = line.length();
-
- // Splitting the line
- final List splitted = new ArrayList<>();
- StringBuilder current = null;
- boolean quotes = false;
- for (int i = 0; i < size; i++)
- {
- final char c = line.charAt(i);
- if (current == null)
- {
- if (c == '"')
- {
- current = new StringBuilder();
- quotes = true;
- }
- else if (c > ' ')
- {
- current = new StringBuilder();
- current.append(c);
- quotes = false;
- }
- }
- else
- {
- boolean closeCurrent;
- if (quotes)
- {
- closeCurrent = (c == '"');
- }
- else
- {
- closeCurrent = (c <= ' ');
- }
- if (closeCurrent)
- {
- if (current.length() > 0)
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- }
- current = null;
- }
- else
- {
- current.append(c);
- }
- }
- }
-
- if ((current != null) && (current.length() > 0))
- {
- String str = current.toString();
- if (quotes)
- {
- str = escape(str);
- }
- splitted.add(str);
- current = null;
- }
-
- // Analyzing
- size = splitted.size();
- int status = 0;
- // Status values:
- // 0 -> fetching environment variables, working directory and channels
- // 1 -> fetching the command and its arguments
- String dirString = null;
- File stdinFile = null;
- File stdoutFile = null;
- File stderrFile = null;
- final List envsList = new ArrayList<>();
- String command = null;
- final List argsList = new ArrayList<>();
- for (int i = 0; i < size; i++)
- {
- final String tk = splitted.get(i);
-
- // Check the local status.
- if (status == 0)
- {
- // Environment variables, working directory and channels
- if (tk.startsWith("ENV:"))
- {
- envsList.add(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("DIR:"))
- {
- dirString = tk.substring(4);
- continue;
- }
- else if (tk.startsWith("IN:"))
- {
- stdinFile = new File(tk.substring(3));
- continue;
- }
- else if (tk.startsWith("OUT:"))
- {
- stdoutFile = new File(tk.substring(4));
- continue;
- }
- else if (tk.startsWith("ERR:"))
- {
- stderrFile = new File(tk.substring(4));
- continue;
- }
- else
- {
- status = 1;
- }
- }
- if (status == 1)
- {
- // Command or argument?
- if (command == null)
- {
- command = tk;
- }
- else
- {
- argsList.add(tk);
- }
- }
- }
-
- // Task preparing.
- Task task;
-
- // Command evaluation.
- if (command == null)
- {
- // No command!
- throw new Exception("Invalid cron line: " + line);
- }
- else if (command.startsWith("java:"))
- {
- // Java inner-process.
- String className = command.substring(5);
- if (className.isEmpty())
- {
- throw new Exception("Invalid Java class name on line: " + line);
- }
- String methodName;
- final int sep = className.indexOf('#');
- if (sep == -1)
- {
- methodName = "main";
- }
- else
- {
- methodName = className.substring(sep + 1);
- className = className.substring(0, sep);
- if (methodName.isEmpty())
- {
- throw new Exception("Invalid Java method name on line: " + line);
- }
- }
- final String[] args = new String[argsList.size()];
- for (int i = 0; i < argsList.size(); i++)
- {
- args[i] = argsList.get(i);
- }
- task = new StaticMethodTask(className, methodName, args);
- }
- else
- {
- // External command.
- final String[] cmdarray = new String[1 + argsList.size()];
- cmdarray[0] = command;
- for (int i = 0; i < argsList.size(); i++)
- {
- cmdarray[i + 1] = argsList.get(i);
- }
-
- // Environments.
- String[] envs = null;
- size = envsList.size();
- if (size > 0)
- {
- envs = new String[size];
- for (int i = 0; i < size; i++)
- {
- envs[i] = envsList.get(i);
- }
- }
-
- // Working directory.
- File dir = null;
- if (dirString != null)
- {
- dir = new File(dirString);
- if (!dir.exists() || !dir.isDirectory())
- {
- throw new Exception("Invalid cron working directory parameter at line: " + line, new FileNotFoundException(dirString + " doesn't exist or it is not a directory"));
- }
- }
-
- // Builds the task.
- final ProcessTask process = new ProcessTask(cmdarray, envs, dir);
-
- // Channels.
- if (stdinFile != null)
- {
- process.setStdinFile(stdinFile);
- }
- if (stdoutFile != null)
- {
- process.setStdoutFile(stdoutFile);
- }
- if (stderrFile != null)
- {
- process.setStderrFile(stderrFile);
- }
- task = process;
- }
-
- // End.
- table.add(new SchedulingPattern(pattern), task);
- }
-
- /**
- * Escapes special chars occurrences.
- * @param str The input stream.
- * @return The decoded output stream.
- */
- private static String escape(String str)
- {
- final int size = str.length();
- final StringBuilder b = new StringBuilder();
- for (int i = 0; i < size; i++)
- {
- int skip = 0;
- final char c = str.charAt(i);
- if ((c == '\\') && (i < (size - 1)))
- {
- final char d = str.charAt(i + 1);
- if (d == '"')
- {
- b.append('"');
- skip = 2;
- }
- else if (d == '\\')
- {
- b.append('\\');
- skip = 2;
- }
- else if (d == '/')
- {
- b.append('/');
- skip = 2;
- }
- else if (d == 'b')
- {
- b.append('\b');
- skip = 2;
- }
- else if (d == 'f')
- {
- b.append('\f');
- skip = 2;
- }
- else if (d == 'n')
- {
- b.append('\n');
- skip = 2;
- }
- else if (d == 'r')
- {
- b.append('\r');
- skip = 2;
- }
- else if (d == 't')
- {
- b.append('\t');
- skip = 2;
- }
- else if (d == 'u')
- {
- if (i < (size - 5))
- {
- final String hex = str.substring(i + 2, i + 6);
- try
- {
- final int code = Integer.parseInt(hex, 16);
- if (code >= 0)
- {
- b.append((char) code);
- skip = 6;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- if (skip == 0)
- {
- b.append(c);
- }
- else
- {
- i += (skip - 1);
- }
- }
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
deleted file mode 100644
index 99250d9a1c..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/DayOfMonthValueMatcher.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array and, if not, checks whether the last-day-of-month setting applies.
- *
- * @author Paul Fernley
- */
-class DayOfMonthValueMatcher extends IntArrayValueMatcher
-{
- private static final int[] lastDays =
- {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- };
-
- /**
- * Builds the ValueMatcher.
- * @param values An ArrayList of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list or the last-day-of-month setting applies.
- */
- public DayOfMonthValueMatcher(List> values)
- {
- super(values);
- }
-
- /**
- * Returns true if the given value is included in the matcher list or the last-day-of-month setting applies.
- * @param value
- * @param month
- * @param isLeapYear
- * @return
- */
- public boolean match(int value, int month, boolean isLeapYear)
- {
- return (super.match(value) || ((value > 27) && match(32) && isLastDayOfMonth(value, month, isLeapYear)));
- }
-
- public boolean isLastDayOfMonth(int value, int month, boolean isLeapYear)
- {
- if (isLeapYear && (month == 2))
- {
- return value == 29;
- }
- return value == lastDays[month - 1];
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
deleted file mode 100644
index 237b664827..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/FileTaskCollector.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation, reading the task list from a group of files.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class FileTaskCollector implements TaskCollector
-{
- /**
- * File list.
- */
- private final List files = new ArrayList<>();
-
- /**
- * Adds a file.
- * @param file The file.
- */
- public synchronized void addFile(File file)
- {
- files.add(file);
- }
-
- /**
- * Removes a file.
- * @param file The file.
- */
- public synchronized void removeFile(File file)
- {
- files.remove(file);
- }
-
- /**
- * Returns the file list.
- * @return The file list.
- */
- public synchronized File[] getFiles()
- {
- final int size = files.size();
- final File[] ret = new File[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = files.get(i);
- }
- return ret;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = files.size();
- for (int i = 0; i < size; i++)
- {
- final File f = files.get(i);
- TaskTable aux = null;
- try
- {
- aux = CronParser.parse(f);
- }
- catch (IOException e)
- {
- final Exception e1 = new Exception("Cannot parse cron file: " + f.getAbsolutePath(), e);
- e1.printStackTrace();
- }
- if (aux != null)
- {
- final int auxSize = aux.size();
- for (int j = 0; j < auxSize; j++)
- {
- ret.add(aux.getSchedulingPattern(j), aux.getTask(j));
- }
- }
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
deleted file mode 100644
index f6292e5db6..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/GUIDGenerator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-/**
- * A GUID generator.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class GUIDGenerator
-{
- /**
- * The machine descriptor, which is used to identified the underlying hardware machine.
- */
- private static String MACHINE_DESCRIPTOR = getMachineDescriptor();
-
- /**
- * Generates a GUID (48 chars).
- * @return The generated GUID.
- */
- public static String generate()
- {
- final StringBuilder id = new StringBuilder();
- encode(id, MACHINE_DESCRIPTOR);
- encode(id, Runtime.getRuntime());
- encode(id, Thread.currentThread());
- encode(id, System.currentTimeMillis());
- encode(id, getRandomInt());
- return id.toString();
- }
-
- /**
- * Calculates a machine id, as an integer value.
- * @return The calculated machine id.
- */
- private static String getMachineDescriptor()
- {
- final StringBuilder descriptor = new StringBuilder();
- descriptor.append(System.getProperty("os.name"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.arch"));
- descriptor.append("::");
- descriptor.append(System.getProperty("os.version"));
- descriptor.append("::");
- descriptor.append(System.getProperty("user.name"));
- descriptor.append("::");
- final StringBuilder b = buildNetworkInterfaceDescriptor();
- if (b != null)
- {
- descriptor.append(b);
- }
- else
- {
- // plain old InetAddress...
- InetAddress addr;
- try
- {
- addr = InetAddress.getLocalHost();
- descriptor.append(addr.getHostAddress());
- }
- catch (UnknownHostException e)
- {
- }
- }
- return descriptor.toString();
- }
-
- /**
- * Builds a descriptor fragment using the {@link NetworkInterface} class, available since Java 1.4.
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder buildNetworkInterfaceDescriptor()
- {
- Enumeration> e1;
- try
- {
- e1 = NetworkInterface.getNetworkInterfaces();
- }
- catch (Throwable t)
- {
- // not available
- return null;
- }
- final StringBuilder b = new StringBuilder();
- while (e1.hasMoreElements())
- {
- final NetworkInterface ni = (NetworkInterface) e1.nextElement();
- final StringBuilder b1 = getMACAddressDescriptor(ni);
- final StringBuilder b2 = getInetAddressDescriptor(ni);
- final StringBuilder b3 = new StringBuilder();
- if (b1 != null)
- {
- b3.append(b1);
- }
- if (b2 != null)
- {
- if (b3.length() > 0)
- {
- b3.append('=');
- }
- b3.append(b2);
- }
- if (b3.length() > 0)
- {
- if (b.length() > 0)
- {
- b.append(';');
- }
- b.append(b3);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine MAC address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getMACAddressDescriptor(NetworkInterface ni)
- {
- byte[] haddr;
- try
- {
- haddr = ni.getHardwareAddress();
- }
- catch (Throwable t)
- {
- // not available.
- haddr = null;
- }
- final StringBuilder b = new StringBuilder();
- if (haddr != null)
- {
- for (byte element : haddr)
- {
- if (b.length() > 0)
- {
- b.append("-");
- }
- final String hex = Integer.toHexString(0xff & element);
- if (hex.length() == 1)
- {
- b.append('0');
- }
- b.append(hex);
- }
- }
- return b;
- }
-
- /**
- * Builds a descriptor fragment using the machine inet address.
- * @param ni NetworkInterface
- * @return A descriptor fragment, or null if the method fails.
- */
- private static StringBuilder getInetAddressDescriptor(NetworkInterface ni)
- {
- final StringBuilder b = new StringBuilder();
- final Enumeration> e2 = ni.getInetAddresses();
- while (e2.hasMoreElements())
- {
- final InetAddress addr = (InetAddress) e2.nextElement();
- if (b.length() > 0)
- {
- b.append(',');
- }
- b.append(addr.getHostAddress());
- }
- return b;
- }
-
- /**
- * Returns a random integer value.
- * @return A random integer value.
- */
- private static int getRandomInt()
- {
- return (int) Math.round((Math.random() * Integer.MAX_VALUE));
- }
-
- /**
- * Encodes an object and appends it to the buffer.
- * @param b The buffer.
- * @param obj The object.
- */
- private static void encode(StringBuilder b, Object obj)
- {
- encode(b, obj.hashCode());
- }
-
- /**
- * Encodes an integer value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, int value)
- {
- final String hex = Integer.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 8; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-
- /**
- * Encodes a long value and appends it to the buffer.
- * @param b The buffer.
- * @param value The value.
- */
- private static void encode(StringBuilder b, long value)
- {
- final String hex = Long.toHexString(value);
- final int hexSize = hex.length();
- for (int i = 16; i > hexSize; i--)
- {
- b.append('0');
- }
- b.append(hex);
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
deleted file mode 100644
index 484b3ec5a6..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/IntArrayValueMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.List;
-
-/**
- *
- * A ValueMatcher whose rules are in a plain array of integer values. When asked to validate a value, this ValueMatcher checks if it is in the array.
- *
- * @author Carlo Pelliccia
- */
-class IntArrayValueMatcher implements ValueMatcher
-{
- /**
- * The accepted values.
- */
- private final int[] values;
-
- /**
- * Builds the ValueMatcher.
- * @param integers An List of Integer elements, one for every value accepted by the matcher. The match() method will return true only if its parameter will be one of this list.
- */
- public IntArrayValueMatcher(List> integers)
- {
- final int size = integers.size();
- values = new int[size];
- for (int i = 0; i < size; i++)
- {
- try
- {
- values[i] = ((Integer) integers.get(i)).intValue();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
- }
-
- /**
- * Returns true if the given value is included in the matcher list.
- * @param value
- * @return
- */
- @Override
- public boolean match(int value)
- {
- for (int value2 : values)
- {
- if (value2 == value)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
deleted file mode 100644
index 16c4e72ebc..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/InvalidPatternException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * This kind of exception is thrown if an invalid scheduling pattern is encountered by the scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class InvalidPatternException extends RuntimeException
-{
- /**
- * Package-reserved construction.
- */
- InvalidPatternException()
- {
- }
-
- /**
- * Package-reserved construction.
- * @param message String
- */
- InvalidPatternException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
deleted file mode 100644
index 6f735db8a8..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/LauncherThread.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- * LauncherThreads are used by {@link Scheduler} instances. A LauncherThread retrieves a list of task from a set of {@link TaskCollector}s. Then it launches, within a separate {@link TaskExecutor}, every retrieved task whose scheduling pattern matches the given reference time.
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class LauncherThread extends Thread
-{
- /**
- * A GUID for this object.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The owner scheduler.
- */
- private final Scheduler scheduler;
-
- /**
- * Task collectors, used to retrieve registered tasks.
- */
- private final TaskCollector[] collectors;
-
- /**
- * A reference time for task launching.
- */
- private final long referenceTimeInMillis;
-
- /**
- * Builds the launcher.
- * @param scheduler The owner scheduler.
- * @param collectors Task collectors, used to retrieve registered tasks.
- * @param referenceTimeInMillis A reference time for task launching.
- */
- public LauncherThread(Scheduler scheduler, TaskCollector[] collectors, long referenceTimeInMillis)
- {
- this.scheduler = scheduler;
- this.collectors = collectors;
- this.referenceTimeInMillis = referenceTimeInMillis;
- // Thread name.
- final String name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]";
- setName(name);
- }
-
- /**
- * Returns the GUID for this object.
- * @return The GUID for this object.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- * Overrides {@link Thread#run()}.
- */
- @Override
- public void run()
- {
- outer: for (TaskCollector collector : collectors)
- {
- final TaskTable taskTable = collector.getTasks();
- final int size = taskTable.size();
- for (int j = 0; j < size; j++)
- {
- if (isInterrupted())
- {
- break outer;
- }
- final SchedulingPattern pattern = taskTable.getSchedulingPattern(j);
- if (pattern.match(scheduler.getTimeZone(), referenceTimeInMillis))
- {
- final Task task = taskTable.getTask(j);
- scheduler.spawnExecutor(task);
- }
- }
- }
- // Notifies completed.
- scheduler.notifyLauncherCompleted(this);
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
deleted file mode 100644
index 01d063045a..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/MemoryTaskCollector.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * A {@link TaskCollector} implementation managing a task list in memory.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class MemoryTaskCollector implements TaskCollector
-{
- /**
- * Size.
- */
- private final int size = 0;
-
- /**
- * The inner scheduling pattern list.
- */
- private final List patterns = new ArrayList<>();
-
- /**
- * The inner task list.
- */
- private final List tasks = new ArrayList<>();
-
- /**
- * IDs for task-pattern couples.
- */
- private final List ids = new ArrayList<>();
-
- /**
- * Counts how many task are currently collected by this collector.
- * @return The size of the currently collected task list.
- */
- public synchronized int size()
- {
- return size;
- }
-
- /**
- * Adds a pattern and a task to the collector.
- * @param pattern The scheduling pattern.
- * @param task The task.
- * @return An ID for the scheduled operation.
- */
- public synchronized String add(SchedulingPattern pattern, Task task)
- {
- final String id = GUIDGenerator.generate();
- patterns.add(pattern);
- tasks.add(task);
- ids.add(id);
- return id;
- }
-
- /**
- * Updates a scheduling pattern in the collector.
- * @param id The ID of the scheduled couple.
- * @param pattern SchedulingPattern
- */
- public synchronized void update(String id, SchedulingPattern pattern)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- patterns.set(index, pattern);
- }
- }
-
- /**
- * Removes a task and its scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @throws IndexOutOfBoundsException
- */
- public synchronized void remove(String id) throws IndexOutOfBoundsException
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- tasks.remove(index);
- patterns.remove(index);
- ids.remove(index);
- }
- }
-
- /**
- * Retrieves a task from the collector.
- * @param id The ID of the scheduled couple.
- * @return The task with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized Task getTask(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return tasks.get(index);
- }
- return null;
- }
-
- /**
- * Retrieves a scheduling pattern from the collector.
- * @param id The ID of the scheduled couple.
- * @return The scheduling pattern with the specified assigned ID, or null if it doesn't exist.
- */
- public synchronized SchedulingPattern getSchedulingPattern(String id)
- {
- final int index = ids.indexOf(id);
- if (index > -1)
- {
- return patterns.get(index);
- }
- return null;
- }
-
- /**
- * Implements {@link TaskCollector#getTasks()}.
- */
- @Override
- public synchronized TaskTable getTasks()
- {
- final TaskTable ret = new TaskTable();
- final int size = tasks.size();
- for (int i = 0; i < size; i++)
- {
- final Task t = tasks.get(i);
- final SchedulingPattern p = patterns.get(i);
- ret.add(p, t);
- }
- return ret;
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
deleted file mode 100644
index 7c8d594abe..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/PastPredictor.java
+++ /dev/null
@@ -1,314 +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 .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * @author UnAfraid
- */
-public class PastPredictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern _schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long _time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone _timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- _schedulingPattern = new SchedulingPattern(schedulingPattern);
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public PastPredictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, long start)
- {
- _schedulingPattern = schedulingPattern;
- _time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public PastPredictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- _timeZone = timeZone;
- }
-
- /**
- * It returns the previous matching moment as a millis value.
- * @return The previous matching moment as a millis value.
- */
- public synchronized long prevMatchingTime()
- {
- // Go a minute back.
- _time -= 60000;
- // Is it matching?
- if (_schedulingPattern.match(_time))
- {
- return _time;
- }
- // Go through the matcher groups.
- final int size = _schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(_time);
- c.setTimeZone(_timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = _schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = _schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = _schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = _schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = _schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute--;
- if (minute < 0)
- {
- minute = 59;
- hour--;
- }
- }
- if (hour < 0)
- {
- hour = 23;
- dayOfMonth--;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour--;
- minute = 59;
- }
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- }
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth--;
- hour = 23;
- minute = 59;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month--;
- dayOfMonth = 31;
- hour = 23;
- minute = 59;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- int oldDayOfMonth = dayOfMonth;
- int oldMonth = month;
- int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- do
- {
- dayOfMonth = oldDayOfMonth - 1;
- month = oldMonth;
- year = oldYear;
- c = new GregorianCalendar();
- c.setTimeZone(_timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- oldDayOfMonth = dayOfMonth;
- oldMonth = month;
- oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- }
- while ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear));
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth--;
- hour = 23;
- minute = 59;
- if (dayOfMonth < 1)
- {
- dayOfMonth = 31;
- month--;
- if (month < Calendar.JANUARY)
- {
- month = Calendar.DECEMBER;
- year--;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- _time = min;
- // Here it is.
- return _time;
- }
-
- /**
- * It returns the previous matching moment as a {@link Date} object.
- * @return The previous matching moment as a {@link Date} object.
- */
- public synchronized Date prevMatchingDate()
- {
- return new Date(prevMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
deleted file mode 100644
index 61f4f9aaa4..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/Predictor.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- *
- * A predictor is able to predict when a scheduling pattern will be matched.
- *
- *
- * Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
- *
- *
- *
- * String pattern = "0 3 * jan-jun,sep-dec mon-fri";
- * Predictor p = new Predictor(pattern);
- * for (int i = 0; i < n; i++)
- * {
- * System.out.println(p.nextMatchingDate());
- * }
- *
- *
- * @author Carlo Pelliccia
- * @since 1.1
- */
-public class Predictor
-{
- /**
- * The scheduling pattern on which the predictor works.
- */
- private final SchedulingPattern schedulingPattern;
-
- /**
- * The start time for the next prediction.
- */
- private long time;
-
- /**
- * The time zone for the prediction.
- */
- private TimeZone timeZone = TimeZone.getDefault();
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, long start) throws InvalidPatternException
- {
- this.schedulingPattern = new SchedulingPattern(schedulingPattern);
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern, Date start) throws InvalidPatternException
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @throws InvalidPatternException In the given scheduling pattern isn't valid.
- */
- public Predictor(String schedulingPattern) throws InvalidPatternException
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, long start)
- {
- this.schedulingPattern = schedulingPattern;
- time = (start / (1000 * 60)) * 1000 * 60;
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @param start The start time of the prediction.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern, Date start)
- {
- this(schedulingPattern, start.getTime());
- }
-
- /**
- * It builds a predictor with the given scheduling pattern and the current system time as the prediction start time.
- * @param schedulingPattern The pattern on which the prediction will be based.
- * @since 2.0
- */
- public Predictor(SchedulingPattern schedulingPattern)
- {
- this(schedulingPattern, System.currentTimeMillis());
- }
-
- /**
- * Sets the time zone for predictions.
- * @param timeZone The time zone for predictions.
- * @since 2.2.5
- */
- public void setTimeZone(TimeZone timeZone)
- {
- this.timeZone = timeZone;
- }
-
- /**
- * It returns the next matching moment as a millis value.
- * @return The next matching moment as a millis value.
- */
- public synchronized long nextMatchingTime()
- {
- // Go a minute ahead.
- time += 60000;
- // Is it matching?
- if (schedulingPattern.match(time))
- {
- return time;
- }
- // Go through the matcher groups.
- final int size = schedulingPattern.matcherSize;
- final long[] times = new long[size];
- for (int k = 0; k < size; k++)
- {
- // Ok, split the time!
- GregorianCalendar c = new GregorianCalendar();
- c.setTimeInMillis(time);
- c.setTimeZone(timeZone);
- int minute = c.get(Calendar.MINUTE);
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- int month = c.get(Calendar.MONTH);
- int year = c.get(Calendar.YEAR);
- // Gets the matchers.
- final ValueMatcher minuteMatcher = schedulingPattern.minuteMatchers.get(k);
- final ValueMatcher hourMatcher = schedulingPattern.hourMatchers.get(k);
- final ValueMatcher dayOfMonthMatcher = schedulingPattern.dayOfMonthMatchers.get(k);
- final ValueMatcher dayOfWeekMatcher = schedulingPattern.dayOfWeekMatchers.get(k);
- final ValueMatcher monthMatcher = schedulingPattern.monthMatchers.get(k);
- for (;;)
- { // day of week
- for (;;)
- { // month
- for (;;)
- { // day of month
- for (;;)
- { // hour
- for (;;)
- { // minutes
- if (minuteMatcher.match(minute))
- {
- break;
- }
- minute++;
- if (minute > 59)
- {
- minute = 0;
- hour++;
- }
- }
- if (hour > 23)
- {
- hour = 0;
- dayOfMonth++;
- }
- if (hourMatcher.match(hour))
- {
- break;
- }
- hour++;
- minute = 0;
- }
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- }
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- if (dayOfMonthMatcher instanceof DayOfMonthValueMatcher)
- {
- final DayOfMonthValueMatcher aux = (DayOfMonthValueMatcher) dayOfMonthMatcher;
- if (aux.match(dayOfMonth, month + 1, c.isLeapYear(year)))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- else if (dayOfMonthMatcher.match(dayOfMonth))
- {
- break;
- }
- else
- {
- dayOfMonth++;
- hour = 0;
- minute = 0;
- }
- }
- if (monthMatcher.match(month + 1))
- {
- break;
- }
- month++;
- dayOfMonth = 1;
- hour = 0;
- minute = 0;
- }
- // Is this ok?
- c = new GregorianCalendar();
- c.setTimeZone(timeZone);
- c.set(Calendar.MINUTE, minute);
- c.set(Calendar.HOUR_OF_DAY, hour);
- c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.YEAR, year);
- // Day-of-month/month/year compatibility check.
- final int oldDayOfMonth = dayOfMonth;
- final int oldMonth = month;
- final int oldYear = year;
- dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
- month = c.get(Calendar.MONTH);
- year = c.get(Calendar.YEAR);
- if ((month != oldMonth) || (dayOfMonth != oldDayOfMonth) || (year != oldYear))
- {
- // Take another spin!
- continue;
- }
- // Day of week.
- final int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
- if (dayOfWeekMatcher.match(dayOfWeek - 1))
- {
- break;
- }
- dayOfMonth++;
- hour = 0;
- minute = 0;
- if (dayOfMonth > 31)
- {
- dayOfMonth = 1;
- month++;
- if (month > Calendar.DECEMBER)
- {
- month = Calendar.JANUARY;
- year++;
- }
- }
- }
- // Seems it matches!
- times[k] = (c.getTimeInMillis() / (1000 * 60)) * 1000 * 60;
- }
- // Which one?
- long min = Long.MAX_VALUE;
- for (int k = 0; k < size; k++)
- {
- if (times[k] < min)
- {
- min = times[k];
- }
- }
- // Updates the object current time value.
- time = min;
- // Here it is.
- return time;
- }
-
- /**
- * It returns the next matching moment as a {@link Date} object.
- * @return The next matching moment as a {@link Date} object.
- */
- public synchronized Date nextMatchingDate()
- {
- return new Date(nextMatchingTime());
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
deleted file mode 100644
index ffd8cbe9bf..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/ProcessTask.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- *
- * A built-in {@link Task} implementation which can be used to run an external process.
- *
- * @author Carlo Pelliccia
- * @since 2.1
- */
-public class ProcessTask extends Task
-{
- /**
- * The command to launch.
- */
- private String[] command;
-
- /**
- * Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- private String[] envs;
-
- /**
- * Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- private File directory;
-
- /**
- * Standard input file (optional).
- */
- private File stdinFile = null;
-
- /**
- * Standard output file (optional).
- */
- private File stdoutFile = null;
-
- /**
- * Standard error file (optional).
- */
- private File stderrFile = null;
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- * @param directory Working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public ProcessTask(String[] command, String[] envs, File directory)
- {
- this.command = command;
- this.envs = envs;
- this.directory = directory;
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- * @param envs Environment variables for the spawned process, in the form name=value. If null the process will inherit the current JVM environment variables.
- */
- public ProcessTask(String[] command, String[] envs)
- {
- this(command, envs, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch and its arguments.
- */
- public ProcessTask(String[] command)
- {
- this(command, null, null);
- }
-
- /**
- * Creates the task.
- * @param command The command to launch.
- */
- public ProcessTask(String command)
- {
- this(new String[]
- {
- command
- }, null, null);
- }
-
- /**
- * Returns true.
- */
- @Override
- public boolean canBeStopped()
- {
- return true;
- }
-
- /**
- * Returns the command executed by this task.
- * @return The command executed by this task.
- */
- public String[] getCommand()
- {
- return command;
- }
-
- /**
- * Sets the command executed by this task.
- * @param command The command executed by this task.
- */
- public void setCommand(String[] command)
- {
- this.command = command;
- }
-
- /**
- * Returns the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @return The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public String[] getEnvs()
- {
- return envs;
- }
-
- /**
- * Sets the environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- * @param envs The environment variables, in the name=value form, used by the task to run its process. If null the process will inherit the current JVM environment variables.
- */
- public void setEnvs(String[] envs)
- {
- this.envs = envs;
- }
-
- /**
- * Resturns the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @return The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public File getDirectory()
- {
- return directory;
- }
-
- /**
- * Sets the working directory for the spawned process. If null the process will inherit the current JVM working directory.
- * @param directory The working directory for the spawned process. If null the process will inherit the current JVM working directory.
- */
- public void setDirectory(File directory)
- {
- this.directory = directory;
- }
-
- /**
- * Returns the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @return The standard input file (optional).
- */
- public File getStdinFile()
- {
- return stdinFile;
- }
-
- /**
- * Sets the standard input file (optional). If supplied, the standard input channel of the spawned process will be read from the given file.
- * @param stdinFile The standard input file (optional).
- */
- public void setStdinFile(File stdinFile)
- {
- this.stdinFile = stdinFile;
- }
-
- /**
- * Sets the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @param stdoutFile The standard output file (optional).
- */
- public void setStdoutFile(File stdoutFile)
- {
- this.stdoutFile = stdoutFile;
- }
-
- /**
- * Returns the standard output file (optional). If supplied, the standard output channel of the spawned process will be written in the given file.
- * @return The standard output file (optional).
- */
- public File getStdoutFile()
- {
- return stdoutFile;
- }
-
- /**
- * Sets the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @param stderrFile The standard error file (optional).
- */
- public void setStderrFile(File stderrFile)
- {
- this.stderrFile = stderrFile;
- }
-
- /**
- * Returns the standard error file (optional). If supplied, the standard error channel of the spawned process will be written in the given file.
- * @return The standard error file (optional).
- */
- public File getStderrFile()
- {
- return stderrFile;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}. Runs the given command as a separate process and waits for its end.
- */
- @Override
- public void execute(TaskExecutionContext context) throws RuntimeException
- {
- Process p;
- try
- {
- p = exec();
- }
- catch (IOException e)
- {
- throw new RuntimeException(toString() + " cannot be started", e);
- }
- final InputStream in = buildInputStream(stdinFile);
- final OutputStream out = buildOutputStream(stdoutFile);
- final OutputStream err = buildOutputStream(stderrFile);
- if (in != null)
- {
- final StreamBridge b = new StreamBridge(in, p.getOutputStream());
- b.start();
- }
- if (out != null)
- {
- final StreamBridge b = new StreamBridge(p.getInputStream(), out);
- b.start();
- }
- if (err != null)
- {
- final StreamBridge b = new StreamBridge(p.getErrorStream(), err);
- b.start();
- }
- int r;
- try
- {
- r = p.waitFor();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(toString() + " has been interrupted");
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (out != null)
- {
- try
- {
- out.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (err != null)
- {
- try
- {
- err.close();
- }
- catch (Throwable e)
- {
- }
- }
- p.destroy();
- }
- if (r != 0)
- {
- throw new RuntimeException(toString() + " returns with error code " + r);
- }
- }
-
- /**
- * Executes the command.
- * @return The launched Process.
- * @throws IOException If an I/O error occurs.
- */
- private Process exec() throws IOException
- {
- final Runtime rt = Runtime.getRuntime();
- Process p;
- try
- {
- // java 1.3+
- p = rt.exec(command, envs, directory);
- }
- catch (NoSuchMethodError e)
- {
- // java 1.2
- p = rt.exec(command, envs);
- }
- return p;
- }
-
- /**
- * Prepares an {@link InputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private InputStream buildInputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileInputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prepares an {@link OutputStream} on a file and returns it.
- * @param file The file.
- * @return The stream, or null if the file is not found.
- */
- private OutputStream buildOutputStream(File file)
- {
- if (file != null)
- {
- try
- {
- return new FileOutputStream(file);
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return null;
- }
-
- /**
- * Prints in the returned string the elements contained in the given string array.
- * @param arr The array.
- * @return A string representing the supplied array contents.
- */
- private static String listStrings(String[] arr)
- {
- if (arr == null)
- {
- return "null";
- }
- final StringBuilder b = new StringBuilder();
- b.append('[');
- for (int i = 0; i < arr.length; i++)
- {
- if (i > 0)
- {
- b.append(", ");
- }
- b.append(arr[i]);
- }
- b.append(']');
- return b.toString();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("cmd=");
- b.append(listStrings(command));
- b.append(", env=");
- b.append(listStrings(envs));
- b.append(", ");
- b.append("dir=");
- b.append(directory);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
deleted file mode 100644
index 5e42a82c2b..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/RunnableTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * A {@link Task} implementation acting as a wrapper around a {@link Runnable} object.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-class RunnableTask extends Task
-{
- /**
- * The wrapped runnable object.
- */
- private final Runnable runnable;
-
- /**
- * Builds the task.
- * @param runnable The wrapped Runnable object.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public RunnableTask(Runnable runnable) throws InvalidPatternException
- {
- this.runnable = runnable;
- }
-
- /**
- * Returns the wrapped Runnable object.
- * @return The wrapped Runnable object.
- */
- public Runnable getRunnable()
- {
- return runnable;
- }
-
- /**
- * Implements {@link Task#execute(TaskExecutionContext)}, launching the {@link Runnable#run()} method on the wrapped object.
- */
- @Override
- public void execute(TaskExecutionContext context)
- {
- runnable.run();
- }
-
- /**
- * Overrides {@link Object#toString()}.
- */
- @Override
- public String toString()
- {
- final StringBuilder b = new StringBuilder();
- b.append("Task[");
- b.append("runnable=");
- b.append(runnable);
- b.append("]");
- return b.toString();
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
deleted file mode 100644
index efd112dbda..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/Scheduler.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- *
- * The cron4j scheduler.
- *
- * @author Carlo Pelliccia
- */
-public class Scheduler
-{
- /**
- * A GUID for this scheduler.
- */
- private final String guid = GUIDGenerator.generate();
-
- /**
- * The time zone applied by the scheduler.
- */
- private TimeZone timezone = null;
-
- /**
- * The daemon flag. If true the scheduler and its spawned threads acts like daemons.
- */
- private boolean daemon = false;
-
- /**
- * The state flag. If true the scheduler is started and running, otherwise it is paused and no task is launched.
- */
- private boolean started = false;
-
- /**
- * Registered {@link TaskCollector}s list.
- */
- private final List collectors = new ArrayList<>();
-
- /**
- * The {@link MemoryTaskCollector} used for memory stored tasks. Represented here for convenience, it is also the first element in the {@link Scheduler#collectors} list.
- */
- private final MemoryTaskCollector memoryTaskCollector = new MemoryTaskCollector();
-
- /**
- * The {@link FileTaskCollector} used for reading tasks from files. Represented here for convenience, it is also the second element in the {@link Scheduler#collectors} list.
- */
- private final FileTaskCollector fileTaskCollector = new FileTaskCollector();
-
- /**
- * Registered {@link SchedulerListener}s list.
- */
- private final List listeners = new ArrayList<>();
-
- /**
- * The thread checking the clock and requesting the spawning of launcher threads.
- */
- private TimerThread timer = null;
-
- /**
- * Currently running {@link LauncherThread} instances.
- */
- private List launchers = null;
-
- /**
- * Currently running {@link TaskExecutor} instances.
- */
- private List executors = null;
-
- /**
- * Internal lock, used to synchronize status-aware operations.
- */
- private final Object lock = new Object();
-
- /**
- * It builds and prepares a brand new Scheduler instance.
- */
- public Scheduler()
- {
- collectors.add(memoryTaskCollector);
- collectors.add(fileTaskCollector);
- }
-
- /**
- * It returns the GUID for this scheduler.
- * @return The GUID for this scheduler.
- */
- public Object getGuid()
- {
- return guid;
- }
-
- /**
- *
- * Sets the time zone applied by the scheduler.
- *
- *
- * Current system time is adapted to the supplied time zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified time zone. In example, suppose:
- *
- *
- *
System time: 10:00
- *
System time zone: GMT+1
- *
Scheduler time zone: GMT+3
- *
- *
- * The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * *
- * will be executed, while any 0 10 * * * will not.
- *
- * @param timezone The time zone applied by the scheduler.
- */
- public void setTimeZone(TimeZone timezone)
- {
- this.timezone = timezone;
- }
-
- /**
- * Returns the time zone applied by the scheduler.
- * @return The time zone applied by the scheduler.
- */
- public TimeZone getTimeZone()
- {
- return timezone != null ? timezone : TimeZone.getDefault();
- }
-
- /**
- * Tests whether this scheduler is a daemon scheduler.
- * @return true if this scheduler is a daemon scheduler; false otherwise.
- */
- public boolean isDaemon()
- {
- return daemon;
- }
-
- /**
- * Marks this scheduler daemon flag. When a scheduler is marked as a daemon scheduler it spawns only daemon threads. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the scheduler is started.
- * @param on If true, the scheduler will spawn only daemon threads.
- * @throws IllegalStateException If the scheduler is started.
- */
- public void setDaemon(boolean on) throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- daemon = on;
- }
- }
-
- /**
- * Tests if this scheduler is started.
- * @return true if the scheduler is started, false if it is stopped.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- /**
- * Adds a {@link File} instance to the scheduler. Every minute the file will be parsed. The scheduler will execute any declared task whose scheduling pattern matches the current system time. See {@link CronParser} documentation for informations about the file contents syntax.
- * @param file The {@link File} instance.
- */
- public void scheduleFile(File file)
- {
- fileTaskCollector.addFile(file);
- }
-
- /**
- * Removes a {@link File} instance previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @param file The {@link File} instance.
- */
- public void descheduleFile(File file)
- {
- fileTaskCollector.removeFile(file);
- }
-
- /**
- * Returns an array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- * @return An array containing any {@link File} previously scheduled with the {@link Scheduler#scheduleFile(File)} method.
- */
- public File[] getScheduledFiles()
- {
- return fileTaskCollector.getFiles();
- }
-
- /**
- * Adds a custom {@link TaskCollector} instance to the scheduler. The supplied object, once added to the scheduler, will be query every minute for its task list. The scheduler will execute any of the returned tasks whose scheduling pattern matches the current system time.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void addTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.add(collector);
- }
- }
-
- /**
- * Removes a previously registered custom {@link TaskCollector} instance.
- * @param collector The custom {@link TaskCollector} instance.
- */
- public void removeTaskCollector(TaskCollector collector)
- {
- synchronized (collectors)
- {
- collectors.remove(collector);
- }
- }
-
- /**
- * Returns an array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- * @return An array containing any custom {@link TaskCollector} instance previously registered in the scheduler with the {@link Scheduler#addTaskCollector(TaskCollector)} method.
- */
- public TaskCollector[] getTaskCollectors()
- {
- synchronized (collectors)
- {
- // Discard the first 2 elements in the list.
- final int size = collectors.size() - 2;
- final TaskCollector[] ret = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = collectors.get(i + 2);
- }
- return ret;
- }
- }
-
- /**
- * Adds a {@link SchedulerListener} to the scheduler. A {@link SchedulerListener} is notified every time a task is launching, has succeeded or has failed.
- * @param listener The listener.
- */
- public void addSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @param listener The listener.
- */
- public void removeSchedulerListener(SchedulerListener listener)
- {
- synchronized (listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Returns an array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- * @return An array containing any {@link SchedulerListener} previously registered with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method.
- */
- public SchedulerListener[] getSchedulerListeners()
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- final SchedulerListener[] ret = new SchedulerListener[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = listeners.get(i);
- }
- return ret;
- }
- }
-
- /**
- * Returns an array containing any currently executing task, in the form of {@link TaskExecutor} objects. Each running task is executed by a different thread. A {@link TaskExecutor} object allows the control of the running task. The inner {@link Task} representation could be retrieved, the
- * status of the task could be detected and the thread could be interrupted using any standard {@link Thread} method ( {@link Thread#interrupt()}, {@link Thread#isAlive() etc}.
- * @return An array containing any currently executing task, in the form of {@link TaskExecutor} objects.
- */
- public TaskExecutor[] getExecutingTasks()
- {
- synchronized (executors)
- {
- final int size = executors.size();
- final TaskExecutor[] ret = new TaskExecutor[size];
- for (int i = 0; i < size; i++)
- {
- ret[i] = executors.get(i);
- }
- return ret;
- }
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public String schedule(String schedulingPattern, Runnable task) throws InvalidPatternException
- {
- return schedule(schedulingPattern, new RunnableTask(task));
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @since 2.0
- */
- public String schedule(String schedulingPattern, Task task) throws InvalidPatternException
- {
- return schedule(new SchedulingPattern(schedulingPattern), task);
- }
-
- /**
- * This method schedules a task execution.
- * @param schedulingPattern The scheduling pattern for the task.
- * @param task The task, as a plain Runnable object.
- * @return The task auto-generated ID assigned by the scheduler. This ID can be used later to reschedule and deschedule the task, and also to retrieve informations about it.
- * @since 2.0
- */
- public String schedule(SchedulingPattern schedulingPattern, Task task)
- {
- return memoryTaskCollector.add(schedulingPattern, task);
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- * @deprecated Use {@link Scheduler#reschedule(String, String)}.
- */
- @Deprecated
- public void reschedule(Object id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule((String) id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @throws InvalidPatternException If the supplied pattern is not valid.
- */
- public void reschedule(String id, String schedulingPattern) throws InvalidPatternException
- {
- reschedule(id, new SchedulingPattern(schedulingPattern));
- }
-
- /**
- * This method changes the scheduling pattern of a task.
- * @param id The ID assigned to the previously scheduled task.
- * @param schedulingPattern The new scheduling pattern for the task.
- * @since 2.0
- */
- public void reschedule(String id, SchedulingPattern schedulingPattern)
- {
- memoryTaskCollector.update(id, schedulingPattern);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- * @deprecated Use {@link Scheduler#deschedule(String)}.
- */
- @Deprecated
- public void deschedule(Object id)
- {
- deschedule((String) id);
- }
-
- /**
- * This methods cancels the scheduling of a task.
- * @param id The ID of the task.
- */
- public void deschedule(String id)
- {
- memoryTaskCollector.remove(id);
- }
-
- /**
- * This method retrieves a previously scheduled task.
- * @param id The task ID.
- * @return The requested task, or null if the task was not found.
- * @since 2.0
- */
- public Task getTask(String id)
- {
- return memoryTaskCollector.getTask(id);
- }
-
- /**
- * This method retrieves a previously scheduled task scheduling pattern.
- * @param id The task ID.
- * @return The requested scheduling pattern, or null if the task was not found.
- * @since 2.0
- */
- public SchedulingPattern getSchedulingPattern(String id)
- {
- return memoryTaskCollector.getSchedulingPattern(id);
- }
-
- /**
- * This method retrieves the Runnable object of a previously scheduled task.
- * @param id The task ID.
- * @return The Runnable object of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getTask(String)}.
- */
- @Deprecated
- public Runnable getTaskRunnable(Object id)
- {
- final Task task = getTask((String) id);
- if (task instanceof RunnableTask)
- {
- final RunnableTask rt = (RunnableTask) task;
- return rt.getRunnable();
- }
- return null;
- }
-
- /**
- * This method retrieves the scheduling pattern of a previously scheduled task.
- * @param id The task ID.
- * @return The scheduling pattern of the task, or null if the task was not found.
- * @deprecated Use {@link Scheduler#getSchedulingPattern(String)}.
- */
- @Deprecated
- public String getTaskSchedulingPattern(Object id)
- {
- return getSchedulingPattern((String) id).toString();
- }
-
- /**
- * Executes immediately a task, without scheduling it.
- * @param task The task.
- * @return The {@link TaskExecutor} executing the given task.
- * @throws IllegalStateException If the scheduler is not started.
- */
- public TaskExecutor launch(Task task)
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- return spawnExecutor(task);
- }
- }
-
- /**
- * This method starts the scheduler. When the scheduled is started the supplied tasks are executed at the given moment.
- * @throws IllegalStateException Thrown if this scheduler is already started.
- */
- public void start() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (started)
- {
- throw new IllegalStateException("Scheduler already started");
- }
- // Initializes required lists.
- launchers = new ArrayList<>();
- executors = new ArrayList<>();
- // Starts the timer thread.
- timer = new TimerThread(this);
- timer.setDaemon(daemon);
- timer.start();
- // Change the state of the scheduler.
- started = true;
- }
- }
-
- /**
- * This method stops the scheduler execution. Before returning, it waits the end of all the running tasks previously launched. Once the scheduler has been stopped it can be started again with a start() call.
- * @throws IllegalStateException Thrown if this scheduler is not started.
- */
- public void stop() throws IllegalStateException
- {
- synchronized (lock)
- {
- if (!started)
- {
- throw new IllegalStateException("Scheduler not started");
- }
- // Interrupts the timer and waits for its death.
- timer.interrupt();
- tillThreadDies(timer);
- timer = null;
- // Interrupts any running launcher and waits for its death.
- for (;;)
- {
- LauncherThread launcher = null;
- synchronized (launchers)
- {
- if (launchers.size() == 0)
- {
- break;
- }
- launcher = launchers.remove(0);
- }
- launcher.interrupt();
- tillThreadDies(launcher);
- }
- launchers = null;
- // Interrupts any running executor and waits for its death.
- // Before exiting wait for all the active tasks end.
- for (;;)
- {
- TaskExecutor executor = null;
- synchronized (executors)
- {
- if (executors.size() == 0)
- {
- break;
- }
- executor = executors.remove(0);
- }
- if (executor.canBeStopped())
- {
- executor.stop();
- }
- tillExecutorDies(executor);
- }
- executors = null;
- // Change the state of the object.
- started = false;
- }
- }
-
- // -- PACKAGE RESERVED METHODS --------------------------------------------
-
- /**
- * Starts a launcher thread.
- * @param referenceTimeInMillis Reference time in millis for the launcher.
- * @return The spawned launcher.
- */
- LauncherThread spawnLauncher(long referenceTimeInMillis)
- {
- TaskCollector[] nowCollectors;
- synchronized (collectors)
- {
- final int size = collectors.size();
- nowCollectors = new TaskCollector[size];
- for (int i = 0; i < size; i++)
- {
- nowCollectors[i] = collectors.get(i);
- }
- }
- final LauncherThread l = new LauncherThread(this, nowCollectors, referenceTimeInMillis);
- synchronized (launchers)
- {
- launchers.add(l);
- }
- l.setDaemon(daemon);
- l.start();
- return l;
- }
-
- /**
- * Starts the given task within a task executor.
- * @param task The task.
- * @return The spawned task executor.
- */
- TaskExecutor spawnExecutor(Task task)
- {
- final TaskExecutor e = new TaskExecutor(this, task);
- synchronized (executors)
- {
- executors.add(e);
- }
- e.start(daemon);
- return e;
- }
-
- /**
- * This method is called by a launcher thread to notify that the execution is completed.
- * @param launcher The launcher which has completed its task.
- */
- void notifyLauncherCompleted(LauncherThread launcher)
- {
- synchronized (launchers)
- {
- launchers.remove(launcher);
- }
- }
-
- /**
- * This method is called by a task executor to notify that the execution is completed.
- * @param executor The executor which has completed its task.
- */
- void notifyExecutorCompleted(TaskExecutor executor)
- {
- synchronized (executors)
- {
- executors.remove(executor);
- }
- }
-
- /**
- * Notifies every registered listener that a task is going to be launched.
- * @param executor The task executor.
- */
- void notifyTaskLaunching(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskLaunching(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has successfully completed.
- * @param executor The task executor.
- */
- void notifyTaskSucceeded(TaskExecutor executor)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskSucceeded(executor);
- }
- }
- }
-
- /**
- * Notifies every registered listener that a task execution has failed due to an uncaught exception.
- * @param executor The task executor.
- * @param exception The exception.
- */
- void notifyTaskFailed(TaskExecutor executor, Throwable exception)
- {
- synchronized (listeners)
- {
- final int size = listeners.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- final SchedulerListener l = listeners.get(i);
- l.taskFailed(executor, exception);
- }
- }
- else
- {
- // Logs on console if no one has been notified about it.
- exception.printStackTrace();
- }
- }
- }
-
- // -- PRIVATE METHODS -----------------------------------------------------
-
- /**
- * It waits until the given thread is dead. It is similar to {@link Thread#join()}, but this one avoids {@link InterruptedException} instances.
- * @param thread The thread.
- */
- private void tillThreadDies(Thread thread)
- {
- boolean dead = false;
- do
- {
- try
- {
- thread.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-
- /**
- * It waits until the given task executor is dead. It is similar to {@link TaskExecutor#join()}, but this one avoids {@link InterruptedException} instances.
- * @param executor The task executor.
- */
- private void tillExecutorDies(TaskExecutor executor)
- {
- boolean dead = false;
- do
- {
- try
- {
- executor.join();
- dead = true;
- }
- catch (InterruptedException e)
- {
- }
- }
- while (!dead);
- }
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
deleted file mode 100644
index fdcb0d8f05..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/SchedulerListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-/**
- *
- * Implement this interface and register your instance with the {@link Scheduler#addSchedulerListener(SchedulerListener)} method to receive notifications about scheduled task executions.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public interface SchedulerListener
-{
- /**
- * This one is called by the scheduler when a task execution is starting.
- * @param executor The task executor.
- */
- void taskLaunching(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has been successfully completed.
- * @param executor The task executor.
- */
- void taskSucceeded(TaskExecutor executor);
-
- /**
- * This one is called by the scheduler to notify that a task execution has failed.
- * @param executor The task executor.
- * @param exception The exception representing the failure notification.
- */
- void taskFailed(TaskExecutor executor, Throwable exception);
-}
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
deleted file mode 100644
index 939b173821..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/cron4j/SchedulingPattern.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * cron4j - A pure Java cron-like scheduler
- *
- * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version
- * 2.1, as published by the Free Software Foundation.
- *
- * 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 Lesser General Public License 2.1 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License version 2.1 along with this program.
- * If not, see .
- */
-package org.l2jmobius.gameserver.util.cron4j;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- *
- * A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intented as:
- *
- *
- *
Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- *
Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- *
Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value L can be used to recognize the last day of month.
- *
Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may",
- * "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- *
Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu",
- * "fri" and "sat".
- *
- *
- * The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
- *
- *
- * Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
- *
- *
- * Some examples:
- *
- *
- * 5 * * * *
- * This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
- *
- *
- * * * * * *
- * This pattern causes a task to be launched every minute.
- *
- *
- * * 12 * * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday.
- *
- *
- * * 12 16 * Mon
- * This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
- *
- *
- * Every sub-pattern can contain two or more comma separated values.
- *
- *
- * 59 11 * * 1,2,3,4,5
- * This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
- *
- *
- * Values intervals are admitted and defined using the minus character.
- *
- *
- * 59 11 * * 1-5
- * This pattern is equivalent to the previous one.
- *
- *
- * The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
- *
- *
- * */5 * * * *
- * This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
- *
- *
- * 3-18/5 * * * *
- * This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
- *
- *
- * */15 9-17 * * *
- * This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
- *
- *
- * All the fresh described syntax rules can be used together.
- *
- *
- * * 12 10-16/2 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
- *
- *
- * * 12 1-15,17,20-25 * *
- * This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
- *
- *
- * Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
- *
- *
- * 0 5 * * *|8 10 * * *|22 17 * * *
- * This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
- *
- * @author Carlo Pelliccia
- * @since 2.0
- */
-public class SchedulingPattern
-{
- /**
- * The parser for the minute values.
- */
- private static final ValueParser MINUTE_VALUE_PARSER = new MinuteValueParser();
-
- /**
- * The parser for the hour values.
- */
- private static final ValueParser HOUR_VALUE_PARSER = new HourValueParser();
-
- /**
- * The parser for the day of month values.
- */
- private static final ValueParser DAY_OF_MONTH_VALUE_PARSER = new DayOfMonthValueParser();
-
- /**
- * The parser for the month values.
- */
- private static final ValueParser MONTH_VALUE_PARSER = new MonthValueParser();
-
- /**
- * The parser for the day of week values.
- */
- private static final ValueParser DAY_OF_WEEK_VALUE_PARSER = new DayOfWeekValueParser();
-
- /**
- * Validates a string as a scheduling pattern.
- * @param schedulingPattern The pattern to validate.
- * @return true if the given string represents a valid scheduling pattern; false otherwise.
- */
- public static boolean validate(String schedulingPattern)
- {
- try
- {
- new SchedulingPattern(schedulingPattern);
- }
- catch (InvalidPatternException e)
- {
- return false;
- }
- return true;
- }
-
- /**
- * The pattern as a string.
- */
- private final String asString;
-
- /**
- * The ValueMatcher list for the "minute" field.
- */
- protected List minuteMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "hour" field.
- */
- protected List hourMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of month" field.
- */
- protected List dayOfMonthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "month" field.
- */
- protected List monthMatchers = new ArrayList<>();
-
- /**
- * The ValueMatcher list for the "day of week" field.
- */
- protected List dayOfWeekMatchers = new ArrayList<>();
-
- /**
- * How many matcher groups in this pattern?
- */
- protected int matcherSize = 0;
-
- /**
- * Builds a SchedulingPattern parsing it from a string.
- * @param pattern The pattern as a crontab-like string.
- * @throws InvalidPatternException If the supplied string is not a valid pattern.
- */
- public SchedulingPattern(String pattern) throws InvalidPatternException
- {
- asString = pattern;
- final StringTokenizer st1 = new StringTokenizer(pattern, "|");
- if (st1.countTokens() < 1)
- {
- throw new InvalidPatternException("invalid pattern: \"" + pattern + "\"");
- }
- while (st1.hasMoreTokens())
- {
- final String localPattern = st1.nextToken();
- final StringTokenizer st2 = new StringTokenizer(localPattern, " \t");
- if (st2.countTokens() != 5)
- {
- throw new InvalidPatternException("invalid pattern: \"" + localPattern + "\"");
- }
- try
- {
- minuteMatchers.add(buildValueMatcher(st2.nextToken(), MINUTE_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing minutes field: " + e.getMessage() + ".");
- }
- try
- {
- hourMatchers.add(buildValueMatcher(st2.nextToken(), HOUR_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing hours field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfMonthMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of month field: " + e.getMessage() + ".");
- }
- try
- {
- monthMatchers.add(buildValueMatcher(st2.nextToken(), MONTH_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing months field: " + e.getMessage() + ".");
- }
- try
- {
- dayOfWeekMatchers.add(buildValueMatcher(st2.nextToken(), DAY_OF_WEEK_VALUE_PARSER));
- }
- catch (Exception e)
- {
- throw new InvalidPatternException("invalid pattern \"" + localPattern + "\". Error parsing days of week field: " + e.getMessage() + ".");
- }
- matcherSize++;
- }
- }
-
- /**
- * A ValueMatcher utility builder.
- * @param str The pattern part for the ValueMatcher creation.
- * @param parser The parser used to parse the values.
- * @return The requested ValueMatcher.
- * @throws Exception If the supplied pattern part is not valid.
- */
- private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception
- {
- if ((str.length() == 1) && str.equals("*"))
- {
- return new AlwaysTrueValueMatcher();
- }
- final List