");
+ return sb.toString();
+ });
+ msg.replace("%name%", holder.getName());
+ msg.replace("%pages%", result.getPagerTemplate());
+ msg.replace("%nodes%", result.getBodyTemplate());
+ activeChar.sendPacket(msg);
+ }
+
+ protected class ZoneNodeHolder
+ {
+ private String _name = "";
+ private Location _changingLoc = null;
+ private final List _nodes = new ArrayList<>();
+
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public void setChangingLoc(Location loc)
+ {
+ _changingLoc = loc;
+ }
+
+ public Location getChangingLoc()
+ {
+ return _changingLoc;
+ }
+
+ public void addNode(Location loc)
+ {
+ _nodes.add(loc);
+ }
+
+ public List getNodes()
+ {
+ return _nodes;
+ }
+
+ public int indexOf(Location loc)
+ {
+ return _nodes.indexOf(loc);
+ }
+ }
+}
diff --git a/L2J_Mobius_HighFive/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java b/L2J_Mobius_HighFive/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java
index 4c21bd5b19..8700a4ec56 100644
--- a/L2J_Mobius_HighFive/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java
+++ b/L2J_Mobius_HighFive/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java
@@ -132,16 +132,7 @@ public class QuestLink implements IBypassHandler
}
else
{
- questId = quest.getId();
- if (questId > 10000)
- {
- questId -= 5000;
- }
- else if (questId == 146)
- {
- questId = 640;
- }
- StringUtil.append(sb, "", String.valueOf(questId), state, "");
+ StringUtil.append(sb, "", String.valueOf(quest.getNpcStringId()), state, "");
}
// sb.append("] ");
sb.append("] ");
diff --git a/L2J_Mobius_HighFive/dist/game/data/scripts/quests/Q00146_TheZeroHour/Q00146_TheZeroHour.java b/L2J_Mobius_HighFive/dist/game/data/scripts/quests/Q00146_TheZeroHour/Q00146_TheZeroHour.java
index 002245f424..c9ead5de6e 100644
--- a/L2J_Mobius_HighFive/dist/game/data/scripts/quests/Q00146_TheZeroHour/Q00146_TheZeroHour.java
+++ b/L2J_Mobius_HighFive/dist/game/data/scripts/quests/Q00146_TheZeroHour/Q00146_TheZeroHour.java
@@ -46,6 +46,12 @@ public class Q00146_TheZeroHour extends Quest
registerQuestItems(FANG);
}
+ @Override
+ public int getNpcStringId()
+ {
+ return 640;
+ }
+
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/CompilationException.java b/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/CompilationException.java
deleted file mode 100644
index 2a30afdeff..0000000000
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/CompilationException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met: Redistributions of source code
- * must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution. Neither the name of the Sun Microsystems nor the names of
- * is contributors may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jmobius.commons.javaengine;
-
-public class CompilationException extends Exception
-{
- public CompilationException(String message)
- {
- super(message);
- }
-}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaCompiler.java b/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaCompiler.java
deleted file mode 100644
index 26a3a0dd27..0000000000
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaCompiler.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met: Redistributions of source code
- * must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution. Neither the name of the Sun Microsystems nor the names of
- * is contributors may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jmobius.commons.javaengine;
-
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
-import javax.tools.JavaCompiler.CompilationTask;
-import javax.tools.JavaFileObject;
-
-import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler;
-
-/**
- * Simple interface to Java compiler using JSR 199 Compiler API.
- * @author A. Sundararajan
- */
-public class JavaCompiler
-{
- private final javax.tools.JavaCompiler tool;
-
- public JavaCompiler()
- {
- tool = new EclipseCompiler();
- }
-
- public Map compile(String source, String fileName)
- {
- return compile(source, fileName, new PrintWriter(System.err), null, null);
- }
-
- public Map compile(String fileName, String source, Writer err)
- {
- return compile(fileName, source, err, null, null);
- }
-
- public Map compile(String fileName, String source, Writer err, String sourcePath)
- {
- return compile(fileName, source, err, sourcePath, null);
- }
-
- /**
- * compile given String source and return bytecodes as a Map.
- * @param fileName source fileName to be used for error messages etc.
- * @param source Java source as String
- * @param err error writer where diagnostic messages are written
- * @param sourcePath location of additional .java source files
- * @param classPath location of additional .class files
- * @return
- */
- public Map compile(String fileName, String source, Writer err, String sourcePath, String classPath)
- {
- // to collect errors, warnings etc.
- final DiagnosticCollector diagnostics = new DiagnosticCollector<>();
-
- // create a new memory JavaFileManager
- final MemoryJavaFileManager manager = new MemoryJavaFileManager();
-
- // prepare the compilation unit
- final List compUnits = new ArrayList<>(1);
- compUnits.add(MemoryJavaFileManager.makeStringSource(fileName, source));
-
- // javac options
- final List options = new ArrayList<>();
- options.add("-warn:-enumSwitch");
- options.add("-g");
- options.add("-deprecation");
- options.add("-1.8");
- if (sourcePath != null)
- {
- options.add("-sourcepath");
- options.add(sourcePath);
- }
- if (classPath != null)
- {
- options.add("-classpath");
- options.add(classPath);
- }
-
- // create a compilation task
- final CompilationTask task = tool.getTask(err, manager, diagnostics, options, null, compUnits);
-
- if (!task.call())
- {
- final PrintWriter perr = new PrintWriter(err);
- for (Diagnostic> diagnostic : diagnostics.getDiagnostics())
- {
- perr.println(diagnostic.getMessage(Locale.getDefault()));
- }
- perr.flush();
- return null;
- }
-
- final Map classBytes = manager.getClassBytes();
- manager.close();
- return classBytes;
- }
-}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaScriptEngine.java b/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaScriptEngine.java
deleted file mode 100644
index b9e1152b4b..0000000000
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaScriptEngine.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met: Redistributions of source code
- * must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution. Neither the name of the Sun Microsystems nor the names of
- * is contributors may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jmobius.commons.javaengine;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.script.AbstractScriptEngine;
-import javax.script.Bindings;
-import javax.script.Compilable;
-import javax.script.CompiledScript;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptException;
-import javax.script.SimpleBindings;
-
-/**
- * This is script engine for Java programming language.
- * @author A. Sundararajan
- */
-public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
-{
- // Java compiler
- private final JavaCompiler compiler;
-
- public JavaScriptEngine()
- {
- compiler = new JavaCompiler();
- }
-
- // my factory, may be null
- private ScriptEngineFactory factory;
-
- // my implementation for CompiledScript
- private static class JavaCompiledScript extends CompiledScript implements Serializable
- {
- private final transient JavaScriptEngine _engine;
- private transient Class> _class;
- private final Map _classBytes;
- private final String _classPath;
-
- JavaCompiledScript(JavaScriptEngine engine, Map classBytes, String classPath)
- {
- _engine = engine;
- _classBytes = classBytes;
- _classPath = classPath;
- }
-
- @Override
- public ScriptEngine getEngine()
- {
- return _engine;
- }
-
- @Override
- public Object eval(ScriptContext ctx) throws ScriptException
- {
- if (_class == null)
- {
- final Map classBytesCopy = new HashMap<>();
- classBytesCopy.putAll(_classBytes);
- _class = JavaScriptEngine.parseMain(new MemoryClassLoader(classBytesCopy, _classPath, JavaScriptEngine.getParentLoader(ctx)), ctx);
- }
- return JavaScriptEngine.evalClass(_class, ctx);
- }
- }
-
- @Override
- public CompiledScript compile(String script) throws ScriptException
- {
- return compile(script, context);
- }
-
- @Override
- public CompiledScript compile(Reader reader) throws ScriptException
- {
- return compile(readFully(reader));
- }
-
- @Override
- public Object eval(String str, ScriptContext ctx) throws ScriptException
- {
- return evalClass(parse(str, ctx), ctx);
- }
-
- @Override
- public Object eval(Reader reader, ScriptContext ctx) throws ScriptException
- {
- return eval(readFully(reader), ctx);
- }
-
- @Override
- public ScriptEngineFactory getFactory()
- {
- synchronized (this)
- {
- if (factory == null)
- {
- factory = new JavaScriptEngineFactory();
- }
- }
- return factory;
- }
-
- @Override
- public Bindings createBindings()
- {
- return new SimpleBindings();
- }
-
- void setFactory(ScriptEngineFactory factory)
- {
- this.factory = factory;
- }
-
- // Internals only below this point
-
- private Class> parse(String str, ScriptContext ctx) throws ScriptException
- {
- final String fileName = getFileName(ctx);
- final String sourcePath = getSourcePath(ctx);
- final String classPath = getClassPath(ctx);
-
- final Writer err = ctx.getErrorWriter() == null ? new StringWriter() : ctx.getErrorWriter();
-
- final Map classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
-
- if (classBytes == null)
- {
- throw err instanceof StringWriter ? new ScriptException(((StringWriter) err).toString()) : new ScriptException("compilation failed");
- }
-
- // create a ClassLoader to load classes from MemoryJavaFileManager
- return parseMain(new MemoryClassLoader(classBytes, classPath, getParentLoader(ctx)), ctx);
- }
-
- protected static Class> parseMain(MemoryClassLoader loader, ScriptContext ctx) throws ScriptException
- {
- final String mainClassName = getMainClassName(ctx);
- if (mainClassName != null)
- {
- try
- {
- final Class> clazz = loader.load(mainClassName);
- final Method mainMethod = findMainMethod(clazz);
- if (mainMethod == null)
- {
- throw new ScriptException("no main method in " + mainClassName);
- }
- return clazz;
- }
- catch (ClassNotFoundException cnfe)
- {
- cnfe.printStackTrace();
- throw new ScriptException(cnfe);
- }
- }
-
- // no main class configured - load all compiled classes
- Iterable> classes;
- try
- {
- classes = loader.loadAll();
- }
- catch (ClassNotFoundException exp)
- {
- throw new ScriptException(exp);
- }
-
- // search for class with main method
- final Class> c = findMainClass(classes);
- if (c != null)
- {
- return c;
- }
-
- // if class with "main" method, then
- // return first class
- final Iterator> itr = classes.iterator();
- return itr.hasNext() ? itr.next() : null;
- }
-
- private JavaCompiledScript compile(String str, ScriptContext ctx) throws ScriptException
- {
- final String fileName = getFileName(ctx);
- final String sourcePath = getSourcePath(ctx);
- final String classPath = getClassPath(ctx);
-
- final Writer err = ctx.getErrorWriter() == null ? new StringWriter() : ctx.getErrorWriter();
- final Map classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
- if (classBytes == null)
- {
- throw err instanceof StringWriter ? new ScriptException(((StringWriter) err).toString()) : new ScriptException("compilation failed");
- }
-
- return new JavaCompiledScript(this, classBytes, classPath);
- }
-
- private static Class> findMainClass(Iterable> classes)
- {
- // find a public class with public static main method
- for (Class> clazz : classes)
- {
- if (Modifier.isPublic(clazz.getModifiers()) && (findMainMethod(clazz) != null))
- {
- return clazz;
- }
- }
-
- // okay, try to find package private class that
- // has public static main method
- for (Class> clazz : classes)
- {
- if (findMainMethod(clazz) != null)
- {
- return clazz;
- }
- }
-
- // no main class found!
- return null;
- }
-
- // find public static void main(String[]) method, if any
- private static Method findMainMethod(Class> clazz)
- {
- try
- {
- final Method mainMethod = clazz.getMethod("main", new Class[]
- {
- String[].class
- });
- final int modifiers = mainMethod.getModifiers();
- if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
- {
- return mainMethod;
- }
- }
- catch (NoSuchMethodException nsme)
- {
- }
- return null;
- }
-
- // find public static void setScriptContext(ScriptContext) method, if any
- private static Method findSetScriptContextMethod(Class> clazz)
- {
- try
- {
- final Method setCtxMethod = clazz.getMethod("setScriptContext", new Class[]
- {
- ScriptContext.class
- });
- final int modifiers = setCtxMethod.getModifiers();
- if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
- {
- return setCtxMethod;
- }
- }
- catch (NoSuchMethodException nsme)
- {
- }
- return null;
- }
-
- private static String getFileName(ScriptContext ctx)
- {
- final int scope = ctx.getAttributesScope("javax.script.filename");
- return scope != -1 ? ctx.getAttribute("javax.script.filename", scope).toString() : "$unnamed.java";
- }
-
- // for certain variables, we look for System properties. This is
- // the prefix used for such System properties
- private static final String SYSPROP_PREFIX = "com.sun.script.java.";
-
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
- private static final String ARGUMENTS = "arguments";
-
- private static String[] getArguments(ScriptContext ctx)
- {
- final int scope = ctx.getAttributesScope(ARGUMENTS);
- if (scope != -1)
- {
- final Object obj = ctx.getAttribute(ARGUMENTS, scope);
- if (obj instanceof String[])
- {
- return (String[]) obj;
- }
- }
- // return zero length array
- return EMPTY_STRING_ARRAY;
- }
-
- private static final String SOURCEPATH = "sourcepath";
-
- private static String getSourcePath(ScriptContext ctx)
- {
- return ctx.getAttributesScope(SOURCEPATH) != -1 ? ctx.getAttribute(SOURCEPATH).toString() : System.getProperty(SYSPROP_PREFIX + SOURCEPATH);
- }
-
- private static final String CLASSPATH = "classpath";
-
- private static String getClassPath(ScriptContext ctx)
- {
- final int scope = ctx.getAttributesScope(CLASSPATH);
- if (scope != -1)
- {
- return ctx.getAttribute(CLASSPATH).toString();
- }
-
- // look for "com.sun.script.java.classpath"
- String res = System.getProperty(SYSPROP_PREFIX + CLASSPATH);
- if (res == null)
- {
- res = System.getProperty("java.class.path");
- }
- return res;
- }
-
- private static final String MAINCLASS = "mainClass";
-
- private static String getMainClassName(ScriptContext ctx)
- {
- return ctx.getAttributesScope(MAINCLASS) != -1 ? ctx.getAttribute(MAINCLASS).toString() : System.getProperty("com.sun.script.java.mainClass");
- }
-
- private static final String PARENTLOADER = "parentLoader";
-
- protected static ClassLoader getParentLoader(ScriptContext ctx)
- {
- final int scope = ctx.getAttributesScope(PARENTLOADER);
- if (scope != -1)
- {
- final Object loader = ctx.getAttribute(PARENTLOADER);
- if (loader instanceof ClassLoader)
- {
- return (ClassLoader) loader;
- }
- }
- return ClassLoader.getSystemClassLoader();
- }
-
- protected static Object evalClass(Class> clazz, ScriptContext ctx) throws ScriptException
- {
- // JSR-223 requirement
- ctx.setAttribute("context", ctx, 100);
- if (clazz == null)
- {
- return null;
- }
- try
- {
- final boolean isPublicClazz = Modifier.isPublic(clazz.getModifiers());
-
- // find the setScriptContext method
- final Method setCtxMethod = findSetScriptContextMethod(clazz);
- // call setScriptContext and pass current ctx variable
- if (setCtxMethod != null)
- {
- if (!isPublicClazz)
- {
- // try to relax access
- setCtxMethod.setAccessible(true);
- }
- setCtxMethod.invoke(null, new Object[]
- {
- ctx
- });
- }
-
- // find the main method
- final Method mainMethod = findMainMethod(clazz);
- if (mainMethod != null)
- {
- if (!isPublicClazz)
- {
- // try to relax access
- mainMethod.setAccessible(true);
- }
-
- // call main method
- mainMethod.invoke(null, new Object[]
- {
- getArguments(ctx)
- });
- }
-
- // return main class as eval's result
- return clazz;
- }
- catch (Exception exp)
- {
- exp.printStackTrace();
- throw new ScriptException(exp);
- }
- }
-
- // read a Reader fully and return the content as string
- private String readFully(Reader reader) throws ScriptException
- {
- final char[] arr = new char[8 * 1024]; // 8K at a time
- final StringBuilder buf = new StringBuilder();
- int numChars;
- try
- {
- while ((numChars = reader.read(arr, 0, arr.length)) > 0)
- {
- buf.append(arr, 0, numChars);
- }
- }
- catch (IOException exp)
- {
- throw new ScriptException(exp);
- }
- return buf.toString();
- }
-}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaScriptEngineFactory.java b/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaScriptEngineFactory.java
deleted file mode 100644
index 60ea899570..0000000000
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/JavaScriptEngineFactory.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met: Redistributions of source code
- * must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution. Neither the name of the Sun Microsystems nor the names of
- * is contributors may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jmobius.commons.javaengine;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-
-/**
- * This is script engine factory for "Java" script engine.
- * @author A. Sundararajan
- */
-public class JavaScriptEngineFactory implements ScriptEngineFactory
-{
- @Override
- public String getEngineName()
- {
- return "java";
- }
-
- @Override
- public String getEngineVersion()
- {
- return "1.8";
- }
-
- @Override
- public List getExtensions()
- {
- return extensions;
- }
-
- @Override
- public String getLanguageName()
- {
- return "java";
- }
-
- @Override
- public String getLanguageVersion()
- {
- return "1.8";
- }
-
- @Override
- public String getMethodCallSyntax(String obj, String m, String... args)
- {
- final StringBuilder buf = new StringBuilder();
- buf.append(obj);
- buf.append('.');
- buf.append(m);
- buf.append('(');
- if (args.length != 0)
- {
- int i = 0;
- for (; i < (args.length - 1); i++)
- {
- buf.append(args[i] + ", ");
- }
- buf.append(args[i]);
- }
- buf.append(')');
- return buf.toString();
- }
-
- @Override
- public List getMimeTypes()
- {
- return mimeTypes;
- }
-
- @Override
- public List getNames()
- {
- return names;
- }
-
- @Override
- public String getOutputStatement(String toDisplay)
- {
- final StringBuilder buf = new StringBuilder();
- buf.append("System.out.print(\"");
- final int len = toDisplay.length();
- for (int i = 0; i < len; i++)
- {
- final char ch = toDisplay.charAt(i);
- switch (ch)
- {
- case 34: // '"'
- {
- buf.append("\\\"");
- break;
- }
- case 92: // '\\'
- {
- buf.append("\\\\");
- break;
- }
- default:
- {
- buf.append(ch);
- break;
- }
- }
- }
- buf.append("\");");
- return buf.toString();
- }
-
- @Override
- public String getParameter(String key)
- {
- if (key.equals("javax.script.engine"))
- {
- return getEngineName();
- }
- if (key.equals("javax.script.engine_version"))
- {
- return getEngineVersion();
- }
- if (key.equals("javax.script.name"))
- {
- return getEngineName();
- }
- if (key.equals("javax.script.language"))
- {
- return getLanguageName();
- }
- if (key.equals("javax.script.language_version"))
- {
- return getLanguageVersion();
- }
- if (key.equals("THREADING"))
- {
- return "MULTITHREADED";
- }
- return null;
- }
-
- @Override
- public String getProgram(String... statements)
- {
- // we generate a Main class with main method
- // that contains all the given statements
-
- final StringBuilder buf = new StringBuilder();
- buf.append("class ");
- buf.append(getClassName());
- buf.append(" {\n");
- buf.append(" public static void main(String[] args) {\n");
- if (statements.length != 0)
- {
- for (String statement : statements)
- {
- buf.append(" ");
- buf.append(statement);
- buf.append(";\n");
- }
- }
- buf.append(" }\n");
- buf.append("}\n");
- return buf.toString();
- }
-
- @Override
- public ScriptEngine getScriptEngine()
- {
- final JavaScriptEngine engine = new JavaScriptEngine();
- engine.setFactory(this);
- return engine;
- }
-
- // used to generate a unique class name in getProgram
- private String getClassName()
- {
- return "com_sun_script_java_Main$" + getNextClassNumber();
- }
-
- private static synchronized long getNextClassNumber()
- {
- return nextClassNum++;
- }
-
- private static long nextClassNum = 0L;
- private static List names;
- private static List extensions;
- private static List mimeTypes;
- static
- {
- names = new ArrayList<>(1);
- names.add("java");
- names = Collections.unmodifiableList(names);
- extensions = names;
- mimeTypes = new ArrayList<>(0);
- mimeTypes = Collections.unmodifiableList(mimeTypes);
- }
-}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/MemoryClassLoader.java b/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/MemoryClassLoader.java
deleted file mode 100644
index a41b2c4a75..0000000000
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/MemoryClassLoader.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met: Redistributions of source code
- * must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution. Neither the name of the Sun Microsystems nor the names of
- * is contributors may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jmobius.commons.javaengine;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * ClassLoader that loads .class bytes from memory.
- * @author A. Sundararajan
- */
-public final class MemoryClassLoader extends URLClassLoader
-{
- private final Map classBytes;
-
- public MemoryClassLoader(Map classBytes, String classPath, ClassLoader parent)
- {
- super(toURLs(classPath), parent);
- this.classBytes = classBytes;
- }
-
- public MemoryClassLoader(Map classBytes, String classPath)
- {
- this(classBytes, classPath, null);
- }
-
- public Class> load(String className) throws ClassNotFoundException
- {
- return loadClass(className);
- }
-
- public Iterable> loadAll() throws ClassNotFoundException
- {
- final List> classes = new ArrayList<>(classBytes.size());
- for (String name : classBytes.keySet())
- {
- classes.add(loadClass(name));
- }
- return classes;
- }
-
- @Override
- protected Class> findClass(String className) throws ClassNotFoundException
- {
- final byte buf[] = classBytes.get(className);
- if (buf != null)
- {
- // clear the bytes in map -- we don't need it anymore
- classBytes.put(className, null);
- return defineClass(className, buf, 0, buf.length);
- }
- return super.findClass(className);
- }
-
- private static URL[] toURLs(String classPath)
- {
- if (classPath == null)
- {
- return new URL[0];
- }
-
- final List list = new ArrayList<>();
- final StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
- while (st.hasMoreTokens())
- {
- final String token = st.nextToken();
- final File file = new File(token);
- if (file.exists())
- {
- try
- {
- list.add(file.toURI().toURL());
- }
- catch (MalformedURLException mue)
- {
- //
- }
- }
- else
- {
- try
- {
- list.add(new URL(token));
- }
- catch (MalformedURLException mue)
- {
- //
- }
- }
- }
-
- final URL res[] = new URL[list.size()];
- list.toArray(res);
- return res;
- }
-}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/MemoryJavaFileManager.java b/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/MemoryJavaFileManager.java
deleted file mode 100644
index 2e38681d3c..0000000000
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/commons/javaengine/MemoryJavaFileManager.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met: Redistributions of source code
- * must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution. Neither the name of the Sun Microsystems nor the names of
- * is contributors may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jmobius.commons.javaengine;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.nio.CharBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.SimpleJavaFileObject;
-
-import org.eclipse.jdt.internal.compiler.tool.EclipseFileManager;
-
-/**
- * JavaFileManager that keeps compiled .class bytes in memory.
- * @author A. Sundararajan
- */
-public final class MemoryJavaFileManager extends EclipseFileManager
-{
- private static final String EXT = ".java";
- protected Map classBytes;
-
- public MemoryJavaFileManager()
- {
- super(null, null);
- classBytes = new HashMap<>();
- }
-
- public Map getClassBytes()
- {
- return classBytes;
- }
-
- @Override
- public void close()
- {
- classBytes = new HashMap<>();
- }
-
- @Override
- public void flush()
- {
- }
-
- /**
- * A file object used to represent Java source coming from a string.
- */
- private static class StringInputBuffer extends SimpleJavaFileObject
- {
- final String code;
-
- StringInputBuffer(String name, String code)
- {
- super(toURI(name), Kind.SOURCE);
- this.code = code;
- }
-
- @Override
- public CharBuffer getCharContent(boolean ignoreEncodingErrors)
- {
- return CharBuffer.wrap(code);
- }
- }
-
- /**
- * A file object that stores Java bytecode into the classBytes map.
- */
- private class ClassOutputBuffer extends SimpleJavaFileObject
- {
- protected final String name;
-
- ClassOutputBuffer(String name)
- {
- super(toURI(name), Kind.CLASS);
- this.name = name;
- }
-
- @Override
- public OutputStream openOutputStream()
- {
- return new FilterOutputStream(new ByteArrayOutputStream())
- {
- @Override
- public void close() throws IOException
- {
- out.close();
- classBytes.put(name, ((ByteArrayOutputStream) out).toByteArray());
- }
- };
- }
- }
-
- @Override
- public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, Kind kind, FileObject sibling) throws IOException
- {
- if (kind == Kind.CLASS)
- {
- return new ClassOutputBuffer(className.replace('/', '.'));
- }
- return super.getJavaFileForOutput(location, className, kind, sibling);
- }
-
- static JavaFileObject makeStringSource(String name, String code)
- {
- return new StringInputBuffer(name, code);
- }
-
- static URI toURI(String name)
- {
- final File file = new File(name);
- if (file.exists())
- {
- return file.toURI();
- }
-
- try
- {
- final StringBuilder newUri = new StringBuilder();
- newUri.append("file:///");
- newUri.append(name.replace('.', '/'));
- if (name.endsWith(EXT))
- {
- newUri.replace(newUri.length() - EXT.length(), newUri.length(), EXT);
- }
- return URI.create(newUri.toString());
- }
- catch (Exception exp)
- {
- return URI.create("file:///com/sun/script/java/java_source");
- }
- }
-}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/engines/items/DocumentItem.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/engines/items/DocumentItem.java
index d4b0910f8d..72d1746f32 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/engines/items/DocumentItem.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/engines/items/DocumentItem.java
@@ -72,7 +72,6 @@ public final class DocumentItem extends DocumentBase
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
-
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("item".equalsIgnoreCase(d.getNodeName()))
@@ -159,14 +158,17 @@ public final class DocumentItem extends DocumentBase
private void makeItem() throws InvocationTargetException
{
+ // If item exists just reload the data.
if (_currentItem.item != null)
{
- return; // item is already created
+ _currentItem.item.set(_currentItem.set);
+ return;
}
+
try
{
- final Constructor> c = Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class);
- _currentItem.item = (L2Item) c.newInstance(_currentItem.set);
+ final Constructor> itemClass = Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class);
+ _currentItem.item = (L2Item) itemClass.newInstance(_currentItem.set);
}
catch (Exception e)
{
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/enums/PlayerAction.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/enums/PlayerAction.java
index a4f5f5aa8f..722babb84a 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/enums/PlayerAction.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/enums/PlayerAction.java
@@ -22,6 +22,8 @@ package com.l2jmobius.gameserver.enums;
public enum PlayerAction
{
ADMIN_COMMAND,
+ ADMIN_POINT_PICKING,
+ ADMIN_SHOW_TERRITORY,
USER_ENGAGE;
private final int _mask;
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/instancemanager/QuestManager.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/instancemanager/QuestManager.java
index 5fc0e039fc..746f00f93b 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/instancemanager/QuestManager.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/instancemanager/QuestManager.java
@@ -47,7 +47,11 @@ public final class QuestManager
public boolean reload(String questFolder)
{
final Quest q = getQuest(questFolder);
- return (q != null) && q.reload();
+ if (q == null)
+ {
+ return false;
+ }
+ return q.reload();
}
/**
@@ -58,7 +62,11 @@ public final class QuestManager
public boolean reload(int questId)
{
final Quest q = getQuest(questId);
- return (q != null) && q.reload();
+ if (q == null)
+ {
+ return false;
+ }
+ return q.reload();
}
/**
@@ -110,20 +118,20 @@ public final class QuestManager
}
/**
- * Calls {@link Quest#saveGlobalData()} in all quests and scripts.
+ * Calls {@link Quest#onSave()} in all quests and scripts.
*/
public void save()
{
// Save quests.
for (Quest quest : _quests.values())
{
- quest.saveGlobalData();
+ quest.onSave();
}
// Save scripts.
for (Quest script : _scripts.values())
{
- script.saveGlobalData();
+ script.onSave();
}
}
@@ -135,7 +143,11 @@ public final class QuestManager
*/
public Quest getQuest(String name)
{
- return _quests.containsKey(name) ? _quests.get(name) : _scripts.get(name);
+ if (_quests.containsKey(name))
+ {
+ return _quests.get(name);
+ }
+ return _scripts.get(name);
}
/**
@@ -184,7 +196,8 @@ public final class QuestManager
if (Config.ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS)
{
- _log.info("Loaded quest " + Util.splitWords(quest.getName().contains("_") ? quest.getName().substring(quest.getName().indexOf('_') + 1) : quest.getName()) + ".");
+ final String questName = quest.getName().contains("_") ? quest.getName().substring(quest.getName().indexOf('_') + 1) : quest.getName();
+ _log.info("Loaded quest " + Util.splitWords(questName) + ".");
}
}
@@ -215,7 +228,7 @@ public final class QuestManager
public boolean unload(Quest ms)
{
- ms.saveGlobalData();
+ ms.onSave();
return removeScript(ms);
}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/EventType.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/EventType.java
index 67b843ed70..7d9758f571 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/EventType.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/EventType.java
@@ -59,6 +59,7 @@ import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerKarma
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLevelChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
+import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMoveRequest;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPKChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionChange;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPChanged;
@@ -202,6 +203,7 @@ public enum EventType
ON_PLAYER_LOGIN(OnPlayerLogin.class, void.class),
ON_PLAYER_LOGOUT(OnPlayerLogout.class, void.class),
ON_PLAYER_PK_CHANGED(OnPlayerPKChanged.class, void.class),
+ ON_PLAYER_MOVE_REQUEST(OnPlayerMoveRequest.class, void.class, TerminateReturn.class),
ON_PLAYER_PROFESSION_CHANGE(OnPlayerProfessionChange.class, void.class),
ON_PLAYER_PVP_CHANGED(OnPlayerPvPChanged.class, void.class),
ON_PLAYER_PVP_KILL(OnPlayerPvPKill.class, void.class),
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/impl/character/player/OnPlayerMoveRequest.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/impl/character/player/OnPlayerMoveRequest.java
new file mode 100644
index 0000000000..fbb066f040
--- /dev/null
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/events/impl/character/player/OnPlayerMoveRequest.java
@@ -0,0 +1,53 @@
+/*
+ * 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 com.l2jmobius.gameserver.model.events.impl.character.player;
+
+import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jmobius.gameserver.model.events.EventType;
+import com.l2jmobius.gameserver.model.events.impl.IBaseEvent;
+
+/**
+ * @author UnAfraid
+ */
+public class OnPlayerMoveRequest implements IBaseEvent
+{
+ private final L2PcInstance _activeChar;
+ private final Location _location;
+
+ public OnPlayerMoveRequest(L2PcInstance activeChar, Location loc)
+ {
+ _activeChar = activeChar;
+ _location = loc;
+ }
+
+ public L2PcInstance getActiveChar()
+ {
+ return _activeChar;
+ }
+
+ public Location getLocation()
+ {
+ return _location;
+ }
+
+ @Override
+ public EventType getType()
+ {
+ return EventType.ON_PLAYER_MOVE_REQUEST;
+ }
+}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Armor.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Armor.java
index 046d948df6..66eeee3b10 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Armor.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Armor.java
@@ -40,6 +40,12 @@ public final class L2Armor extends L2Item
public L2Armor(StatsSet set)
{
super(set);
+ }
+
+ @Override
+ public void set(StatsSet set)
+ {
+ super.set(set);
_type = set.getEnum("armor_type", ArmorType.class, ArmorType.NONE);
final int _bodyPart = getBodyPart();
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java
index 0af4be52cd..5712239820 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java
@@ -32,8 +32,8 @@ public final class L2EtcItem extends L2Item
{
private String _handler;
private EtcItemType _type;
- private final boolean _isBlessed;
- private final List _extractableItems;
+ private boolean _isBlessed;
+ private List _extractableItems;
/**
* Constructor for EtcItem.
@@ -42,6 +42,12 @@ public final class L2EtcItem extends L2Item
public L2EtcItem(StatsSet set)
{
super(set);
+ }
+
+ @Override
+ public void set(StatsSet set)
+ {
+ super.set(set);
_type = set.getEnum("etcitem_type", EtcItemType.class, EtcItemType.NONE);
// l2j custom - L2EtcItemType.SHOT
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Item.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Item.java
index bddb5b61ed..c12dd07952 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Item.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Item.java
@@ -107,40 +107,40 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
public static final int SLOT_MULTI_ALLWEAPON = SLOT_LR_HAND | SLOT_R_HAND;
- private final int _itemId;
- private final int _displayId;
- private final String _name;
- private final String _icon;
- private final int _weight;
- private final boolean _stackable;
- private final MaterialType _materialType;
- private final CrystalType _crystalType;
- private final int _equipReuseDelay;
- private final int _duration;
- private final int _time;
- private final int _autoDestroyTime;
- private final int _bodyPart;
- private final int _referencePrice;
- private final int _crystalCount;
- private final boolean _sellable;
- private final boolean _dropable;
- private final boolean _destroyable;
- private final boolean _tradeable;
- private final boolean _depositable;
- private final int _enchantable;
- private final boolean _elementable;
- private final boolean _questItem;
- private final boolean _freightable;
- private final boolean _allow_self_resurrection;
- private final boolean _is_oly_restricted;
- private final boolean _for_npc;
- private final boolean _common;
- private final boolean _heroItem;
- private final boolean _pvpItem;
- private final boolean _immediate_effect;
- private final boolean _ex_immediate_effect;
- private final int _defaultEnchantLevel;
- private final ActionType _defaultAction;
+ private int _itemId;
+ private int _displayId;
+ private String _name;
+ private String _icon;
+ private int _weight;
+ private boolean _stackable;
+ private MaterialType _materialType;
+ private CrystalType _crystalType;
+ private int _equipReuseDelay;
+ private int _duration;
+ private int _time;
+ private int _autoDestroyTime;
+ private int _bodyPart;
+ private int _referencePrice;
+ private int _crystalCount;
+ private boolean _sellable;
+ private boolean _dropable;
+ private boolean _destroyable;
+ private boolean _tradeable;
+ private boolean _depositable;
+ private int _enchantable;
+ private boolean _elementable;
+ private boolean _questItem;
+ private boolean _freightable;
+ private boolean _allow_self_resurrection;
+ private boolean _is_oly_restricted;
+ private boolean _for_npc;
+ private boolean _common;
+ private boolean _heroItem;
+ private boolean _pvpItem;
+ private boolean _immediate_effect;
+ private boolean _ex_immediate_effect;
+ private int _defaultEnchantLevel;
+ private ActionType _defaultAction;
protected int _type1; // needed for item list (inventory)
protected int _type2; // different lists for armor, weapon, etc
@@ -150,9 +150,9 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
private SkillHolder[] _skillHolder;
private SkillHolder _unequipSkill = null;
- private final int _useSkillDisTime;
- private final int _reuseDelay;
- private final int _sharedReuseGroup;
+ private int _useSkillDisTime;
+ private int _reuseDelay;
+ private int _sharedReuseGroup;
/**
* Constructor of the L2Item that fill class variables.
@@ -160,6 +160,11 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
* @param set : StatsSet corresponding to a set of couples (key,value) for description of the item
*/
protected L2Item(StatsSet set)
+ {
+ set(set);
+ }
+
+ public void set(StatsSet set)
{
_itemId = set.getInt("item_id");
_displayId = set.getInt("displayId", _itemId);
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Weapon.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Weapon.java
index a77aeba526..77a7455079 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Weapon.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/items/L2Weapon.java
@@ -40,19 +40,19 @@ import com.l2jmobius.util.StringUtil;
*/
public final class L2Weapon extends L2Item
{
- private final WeaponType _type;
- private final boolean _isMagicWeapon;
- private final int _rndDam;
- private final int _soulShotCount;
- private final int _spiritShotCount;
- private final int _mpConsume;
- private final int _baseAttackRange;
- private final int _baseAttackAngle;
+ private WeaponType _type;
+ private boolean _isMagicWeapon;
+ private int _rndDam;
+ private int _soulShotCount;
+ private int _spiritShotCount;
+ private int _mpConsume;
+ private int _baseAttackRange;
+ private int _baseAttackAngle;
/**
* Skill that activates when item is enchanted +4 (for duals).
*/
private SkillHolder _enchant4Skill = null;
- private final int _changeWeaponId;
+ private int _changeWeaponId;
// Attached skills for Special Abilities
private SkillHolder _skillsOnMagic;
@@ -60,15 +60,15 @@ public final class L2Weapon extends L2Item
private SkillHolder _skillsOnCrit;
private Condition _skillsOnCritCondition = null;
- private final int _reducedSoulshot;
- private final int _reducedSoulshotChance;
+ private int _reducedSoulshot;
+ private int _reducedSoulshotChance;
- private final int _reducedMpConsume;
- private final int _reducedMpConsumeChance;
+ private int _reducedMpConsume;
+ private int _reducedMpConsumeChance;
- private final boolean _isForceEquip;
- private final boolean _isAttackWeapon;
- private final boolean _useWeaponSkillsOnly;
+ private boolean _isForceEquip;
+ private boolean _isAttackWeapon;
+ private boolean _useWeaponSkillsOnly;
/**
* Constructor for Weapon.
@@ -77,6 +77,12 @@ public final class L2Weapon extends L2Item
public L2Weapon(StatsSet set)
{
super(set);
+ }
+
+ @Override
+ public void set(StatsSet set)
+ {
+ super.set(set);
_type = WeaponType.valueOf(set.getString("weapon_type", "none").toUpperCase());
_type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE;
_type2 = L2Item.TYPE2_WEAPON;
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java
index 68e22ff2fd..721d57ecec 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java
@@ -119,7 +119,7 @@ public class Quest extends AbstractScript implements IIdentifiable
QuestManager.getInstance().addScript(this);
}
- loadGlobalData();
+ onLoad();
}
/**
@@ -145,17 +145,17 @@ public class Quest extends AbstractScript implements IIdentifiable
* Children of this class can implement this function in order to define what variables to load and what structures to save them in.
* By default, nothing is loaded.
*/
- protected void loadGlobalData()
+ protected void onLoad()
{
}
/**
- * The function saveGlobalData is, by default, called at shutdown, for all quests, by the QuestManager.
+ * The function onSave is, by default, called at shutdown, for all quests, by the QuestManager.
* Children of this class can implement this function in order to convert their structures
* into tuples and make calls to save them to the database, if needed.
* By default, nothing is saved.
*/
- public void saveGlobalData()
+ public void onSave()
{
}
@@ -169,6 +169,14 @@ public class Quest extends AbstractScript implements IIdentifiable
return _questId;
}
+ /**
+ * @return the NpcStringId of the current quest, used in Quest link bypass
+ */
+ public int getNpcStringId()
+ {
+ return _questId > 10000 ? _questId - 5000 : _questId;
+ }
+
/**
* Add a new quest state of this quest to the database.
* @param player the owner of the newly created quest state
@@ -2624,7 +2632,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public boolean unload(boolean removeFromList)
{
- saveGlobalData();
+ onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it
// with its code (example: save global data indicating what timer must be restarted).
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java
index 3c498f9e15..b4618d99c9 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java
@@ -134,4 +134,14 @@ public class ZoneNPoly extends L2ZoneForm
GeoData.getInstance().getHeight(x, y, _z1)
};
}
+
+ public int[] getX()
+ {
+ return _p.xpoints;
+ }
+
+ public int[] getY()
+ {
+ return _p.ypoints;
+ }
}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/MoveBackwardToLocation.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/MoveBackwardToLocation.java
index 3fd2243e75..8868165a8f 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/MoveBackwardToLocation.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/MoveBackwardToLocation.java
@@ -22,6 +22,9 @@ import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jmobius.gameserver.model.events.EventDispatcher;
+import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMoveRequest;
+import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.StopMove;
@@ -43,7 +46,6 @@ public class MoveBackwardToLocation extends L2GameClientPacket
private int _originY;
private int _originZ;
- @SuppressWarnings("unused")
private int _moveMovement;
@Override
@@ -99,6 +101,16 @@ public class MoveBackwardToLocation extends L2GameClientPacket
// Validate position packets sends head level.
_targetZ += activeChar.getTemplate().getCollisionHeight();
+ if (_moveMovement == 1)
+ {
+ final TerminateReturn terminate = EventDispatcher.getInstance().notifyEvent(new OnPlayerMoveRequest(activeChar, new Location(_targetX, _targetY, _targetZ)), activeChar, TerminateReturn.class);
+ if ((terminate != null) && terminate.terminate())
+ {
+ activeChar.sendPacket(ActionFailed.STATIC_PACKET);
+ return;
+ }
+ }
+
if (activeChar.getTeleMode() > 0)
{
if (activeChar.getTeleMode() == 1)
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/AbstractHtmlPacket.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/AbstractHtmlPacket.java
index 5c57b136ee..39f293fc2b 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/AbstractHtmlPacket.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/AbstractHtmlPacket.java
@@ -106,6 +106,11 @@ public abstract class AbstractHtmlPacket extends L2GameServerPacket
_html = _html.replaceAll(pattern, value.replaceAll("\\$", "\\\\\\$"));
}
+ public final void replace(String pattern, CharSequence value)
+ {
+ replace(pattern, String.valueOf(value));
+ }
+
public final void replace(String pattern, boolean val)
{
replace(pattern, String.valueOf(val));
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/ExShowTerritory.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/ExShowTerritory.java
new file mode 100644
index 0000000000..6887f2c57e
--- /dev/null
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/ExShowTerritory.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.l2jmobius.gameserver.network.serverpackets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.l2jmobius.gameserver.model.interfaces.ILocational;
+
+/**
+ * Note: There is known issue with this packet, it cannot be removed unless game client is restarted!
+ * @author UnAfraid
+ */
+public class ExShowTerritory extends L2GameServerPacket
+{
+ private final int _minZ;
+ private final int _maxZ;
+ private final List _vertices = new ArrayList<>();
+
+ public ExShowTerritory(int minZ, int maxZ)
+ {
+ _minZ = minZ;
+ _maxZ = maxZ;
+ }
+
+ public void addVertice(ILocational loc)
+ {
+ _vertices.add(loc);
+ }
+
+ @Override
+ protected void writeImpl()
+ {
+ writeC(0xFE);
+ writeH(0x8D);
+ writeD(_vertices.size());
+ writeD(_minZ);
+ writeD(_maxZ);
+ for (ILocational loc : _vertices)
+ {
+ writeD(loc.getX());
+ writeD(loc.getY());
+ }
+ }
+}
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java
index d189975808..e14af419d4 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java
@@ -21,13 +21,16 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;
import java.util.ServiceLoader;
+import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -168,8 +171,8 @@ public final class ScriptEngineManager
// throws exception if not exists or not file
checkExistingFile("ScriptList", SCRIPT_LIST_FILE);
- final LinkedHashMap> files = new LinkedHashMap<>();
- final LinkedList extWithoutEngine = new LinkedList<>();
+ final Map> files = new LinkedHashMap<>();
+ final Set extWithoutEngine = new HashSet<>();
Files.lines(SCRIPT_LIST_FILE).forEach(line ->
{
@@ -201,24 +204,17 @@ public final class ScriptEngineManager
final IExecutionContext engine = getEngineByExtension(ext);
if (engine == null)
{
- if (!extWithoutEngine.contains(ext))
+ if (extWithoutEngine.add(ext))
{
- extWithoutEngine.add(ext);
_log.warning("ScriptEngine: No engine registered for extension " + ext + "!");
}
return;
}
- LinkedList ll = files.get(engine);
- if (ll == null)
- {
- ll = new LinkedList<>();
- files.put(engine, ll);
- }
- ll.add(sourceFile);
+ files.computeIfAbsent(engine, k -> new LinkedList<>()).add(sourceFile);
});
- for (Entry> entry : files.entrySet())
+ for (Entry> entry : files.entrySet())
{
_currentExecutionContext = entry.getKey();
try
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java
index df80d6699f..984d27cfed 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java
@@ -20,8 +20,10 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
+import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Logger;
@@ -98,8 +100,6 @@ public final class JavaExecutionContext extends AbstractExecutionContext options = new LinkedList<>();
addOptionIfNotNull(options, getProperty("source"), "-source");
@@ -132,12 +132,14 @@ public final class JavaExecutionContext extends AbstractExecutionContext sourcePathStrings = new LinkedList<>();
+ final List sourcePathStrings = new LinkedList<>();
for (Path sourcePath : sourcePaths)
{
sourcePathStrings.add(sourcePath.toString());
}
+ final StringWriter strOut = new StringWriter();
+ final PrintWriter out = new PrintWriter(strOut);
final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
if (!compilationSuccess)
{
@@ -168,8 +170,8 @@ public final class JavaExecutionContext extends AbstractExecutionContext executionFailures = new LinkedHashMap<>();
- Iterable compiledClasses = fileManager.getCompiledClasses();
+ final Map executionFailures = new LinkedHashMap<>();
+ final Iterable compiledClasses = fileManager.getCompiledClasses();
for (final Path sourcePath : sourcePaths)
{
boolean found = false;
@@ -223,13 +225,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext executeScript(final Path sourcePath) throws Exception
{
- @SuppressWarnings("serial")
- Map executionFailures = executeScripts(new LinkedList()
- {
- {
- add(sourcePath);
- }
- });
+ final Map executionFailures = executeScripts(Arrays.asList(sourcePath));
if (!executionFailures.isEmpty())
{
return executionFailures.entrySet().iterator().next();
diff --git a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/util/Util.java b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/util/Util.java
index 0dc7e6d04d..fcec30e3c9 100644
--- a/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/util/Util.java
+++ b/L2J_Mobius_HighFive/java/com/l2jmobius/gameserver/util/Util.java
@@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.Locale;
import java.util.StringJoiner;
+import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@@ -992,4 +993,16 @@ public final class Util
}
return false;
}
+
+ public static int parseNextInt(StringTokenizer st, int defaultVal)
+ {
+ try
+ {
+ return Integer.parseInt(st.nextToken().trim());
+ }
+ catch (Exception e)
+ {
+ return defaultVal;
+ }
+ }
}