Removed javaengine and more misc fixes.

Source: L2jUnity free release
This commit is contained in:
MobiusDev
2016-10-22 09:57:31 +00:00
parent f9f769d0ef
commit f1557eb587
24 changed files with 975 additions and 113 deletions

View File

@@ -27,6 +27,8 @@
<admin command="admin_config_server" accessLevel="100" /> <admin command="admin_config_server" accessLevel="100" />
<admin command="admin_gmon" accessLevel="100" /> <admin command="admin_gmon" accessLevel="100" />
<admin command="admin_worldchat" accessLevel="100" /> <admin command="admin_worldchat" accessLevel="100" />
<admin command="admin_zones" accessLevel="100"/>
<admin command="admin_pointpicking" accessLevel="100"/>
<!-- ADMIN ANNOUNCEMENTS --> <!-- ADMIN ANNOUNCEMENTS -->
<admin command="admin_announce" accessLevel="100" /> <admin command="admin_announce" accessLevel="100" />

View File

@@ -0,0 +1,29 @@
<html>
<head>
<title>Zone Editor</title>
</head>
<body>
<center>
<table width=270 border=0 bgcolor="444444">
<tr>
<td><button value="Main" action="bypass -h admin_admin" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
<td><button value="Char" action="bypass -h admin_admin6" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
<td><button value="Game" action="bypass -h admin_admin2" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
<td><button value="GM" action="bypass -h admin_admin7" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
</tr>
</table>
<br>
</center>
<br1>
<center><button value="Create" action="bypass -h admin_zones create" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></center>
<br1>
Zones
<br1>
<center>
<table>
%zones%
</table>
</center>
<br>
</body>
</html>

View File

@@ -0,0 +1,63 @@
<html>
<head>
<title>Zone Creator</title>
</head>
<body>
<center>
<table width=270 border=0 bgcolor="444444">
<tr>
<td><button value="Main" action="bypass -h admin_admin" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
<td><button value="Char" action="bypass -h admin_admin6" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
<td><button value="Game" action="bypass -h admin_admin2" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
<td><button value="GM" action="bypass -h admin_admin7" width=65 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td>
</tr>
</table>
<br>
</center>
<center>
<table>
<tr>
<td><edit var="name" width=127 height=15></td>
<td><button action="bypass -h admin_zones setname $name" value="Set name" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
<tr>
<td><button action="bypass -h admin_zones start" value="Picking" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button action="bypass -h admin_zones finish" value="Moving" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
<tr>
<td><button action="bypass -h admin_zones dump" value="Dump" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button action="bypass -h admin_zones clear" value="Clear" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
<tr>
<td><button action="bypass -h admin_zones show" value="Show" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button action="bypass -h admin_zones hide" value="Hide" width=130 height=19 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>
</center>
<br1>
<table>
<tr>
%pages%
</tr>
</table>
<br1>
Name: <font color="LEVEL">%name%</font>
<br1>
<table width=280 height=20 cellspacing=0 background="L2UI_CT1.Button_DF_Calculator">
<tr>
<td fixwidth=5></td>
<td fixwidth=20>#</td>
<td fixwidth=60>X</td>
<td fixwidth=60>Y</td>
<td fixwidth=60>Z</td>
<td fixwidth=30>Edit</td>
<td fixwidth=30>Tele</td>
<td fixwidth=30>Dele</td>
<td fixwidth=5></td>
</tr>
</table>
<table width=275 cellspacing=0 background="L2UI_CT1.Windows.Windows_DF_TooltipBG">
%nodes%
</table>
</body>
</html>

View File

@@ -97,7 +97,7 @@ public final class Core extends AbstractNpcAI
} }
@Override @Override
public void saveGlobalData() public void onSave()
{ {
saveGlobalQuestVar("Core_Attacked", Boolean.toString(_firstAttacked)); saveGlobalQuestVar("Core_Attacked", Boolean.toString(_firstAttacked));
} }

View File

@@ -130,6 +130,7 @@ import handlers.admincommandhandlers.AdminUnblockIp;
import handlers.admincommandhandlers.AdminVitality; import handlers.admincommandhandlers.AdminVitality;
import handlers.admincommandhandlers.AdminWall; import handlers.admincommandhandlers.AdminWall;
import handlers.admincommandhandlers.AdminZone; import handlers.admincommandhandlers.AdminZone;
import handlers.admincommandhandlers.AdminZones;
import handlers.bypasshandlers.AlternateClassMaster; import handlers.bypasshandlers.AlternateClassMaster;
import handlers.bypasshandlers.ArcanCityMovie; import handlers.bypasshandlers.ArcanCityMovie;
import handlers.bypasshandlers.Augment; import handlers.bypasshandlers.Augment;
@@ -383,6 +384,7 @@ public final class MasterHandler
AdminPetition.class, AdminPetition.class,
AdminPForge.class, AdminPForge.class,
AdminPledge.class, AdminPledge.class,
AdminZones.class,
AdminPolymorph.class, AdminPolymorph.class,
AdminPremium.class, AdminPremium.class,
AdminPrimePoints.class, AdminPrimePoints.class,

View File

@@ -0,0 +1,580 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.admincommandhandlers;
import java.awt.Color;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.enums.PlayerAction;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PageResult;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
import com.l2jmobius.gameserver.model.events.annotations.Priority;
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMoveRequest;
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
import com.l2jmobius.gameserver.model.zone.form.ZoneNPoly;
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
import com.l2jmobius.gameserver.network.serverpackets.ExServerPrimitive;
import com.l2jmobius.gameserver.network.serverpackets.ExShowTerritory;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.util.HtmlUtil;
import com.l2jmobius.gameserver.util.Util;
import com.l2jmobius.util.Rnd;
import ai.AbstractNpcAI;
/**
* @author UnAfraid
*/
public class AdminZones extends AbstractNpcAI implements IAdminCommandHandler
{
private static final Logger _log = Logger.getLogger(AdminPathNode.class.getName());
private final Map<Integer, ZoneNodeHolder> _zones = new ConcurrentHashMap<>();
private static final String[] COMMANDS =
{
"admin_zones",
};
public AdminZones()
{
super(AdminZones.class.getSimpleName(), "handlers");
}
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
switch (cmd)
{
case "admin_zones":
{
if (!st.hasMoreTokens())
{
buildZonesEditorWindow(activeChar);
return false;
}
final String subCmd = st.nextToken();
switch (subCmd)
{
case "load":
{
if (st.hasMoreTokens())
{
String name = "";
while (st.hasMoreTokens())
{
name += st.nextToken() + " ";
}
loadZone(activeChar, name.trim());
}
break;
}
case "create":
{
buildHtmlWindow(activeChar, 0);
break;
}
case "setname":
{
String name = "";
while (st.hasMoreTokens())
{
name += st.nextToken() + " ";
}
if (!name.isEmpty())
{
name = name.substring(0, name.length() - 1);
}
setName(activeChar, name);
break;
}
case "start":
{
enablePicking(activeChar);
break;
}
case "finish":
{
disablePicking(activeChar);
break;
}
case "show":
{
showPoints(activeChar);
final ConfirmDlg dlg = new ConfirmDlg("When enable show territory you must restart client to remove it, are you sure about that?");
dlg.addTime(15 * 1000);
activeChar.sendPacket(dlg);
activeChar.addAction(PlayerAction.ADMIN_SHOW_TERRITORY);
break;
}
case "hide":
{
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
if (holder != null)
{
final ExServerPrimitive exsp = new ExServerPrimitive("DebugPoint_" + activeChar.getObjectId(), activeChar.getX(), activeChar.getY(), activeChar.getZ());
exsp.addPoint(Color.BLACK, 0, 0, 0);
activeChar.sendPacket(exsp);
}
break;
}
case "change":
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Missing node index!");
break;
}
final String indexToken = st.nextToken();
if (!Util.isDigit(indexToken))
{
activeChar.sendMessage("Node index should be int!");
break;
}
final int index = Integer.parseInt(indexToken);
changePoint(activeChar, index);
break;
}
case "delete":
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Missing node index!");
break;
}
final String indexToken = st.nextToken();
if (!Util.isDigit(indexToken))
{
activeChar.sendMessage("Node index should be int!");
break;
}
final int index = Integer.parseInt(indexToken);
deletePoint(activeChar, index);
showPoints(activeChar);
break;
}
case "clear":
{
_zones.remove(activeChar.getObjectId());
break;
}
case "dump":
{
dumpPoints(activeChar);
break;
}
case "list":
{
final int page = Util.parseNextInt(st, 0);
buildHtmlWindow(activeChar, page);
return false;
}
}
break;
}
}
buildHtmlWindow(activeChar, 0);
return false;
}
private void buildZonesEditorWindow(L2PcInstance activeChar)
{
final StringBuilder sb = new StringBuilder();
final List<L2ZoneType> zones = ZoneManager.getInstance().getZones(activeChar);
for (L2ZoneType zone : zones)
{
if (zone.getZone() instanceof ZoneNPoly)
{
sb.append("<tr>");
sb.append("<td fixwidth=200><a action=\"bypass -h admin_zones load " + zone.getName() + "\">" + zone.getName() + "</a></td>");
sb.append("</tr>");
}
}
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/zone_editor.htm");
msg.replace("%zones%", sb.toString());
activeChar.sendPacket(msg);
}
/**
* @param activeChar
* @param zoneName
*/
private void loadZone(L2PcInstance activeChar, String zoneName)
{
activeChar.sendMessage("Searching for zone: " + zoneName);
final List<L2ZoneType> zones = ZoneManager.getInstance().getZones(activeChar);
L2ZoneType zoneType = null;
for (L2ZoneType zone : zones)
{
if (zone.getName().equalsIgnoreCase(zoneName))
{
zoneType = zone;
activeChar.sendMessage("Zone found: " + zone.getId());
break;
}
}
if ((zoneType != null) && (zoneType.getZone() instanceof ZoneNPoly))
{
final ZoneNPoly zone = (ZoneNPoly) zoneType.getZone();
final ZoneNodeHolder holder = _zones.computeIfAbsent(activeChar.getObjectId(), val -> new ZoneNodeHolder());
holder.getNodes().clear();
holder.setName(zoneType.getName());
for (int i = 0; i < zone.getX().length; i++)
{
final int x = zone.getX()[i];
final int y = zone.getY()[i];
holder.addNode(new Location(x, y, GeoData.getInstance().getSpawnHeight(x, y, Rnd.get(zone.getLowZ(), zone.getHighZ()))));
}
showPoints(activeChar);
}
}
/**
* @param activeChar
* @param name
*/
private void setName(L2PcInstance activeChar, String name)
{
if (name.contains("<") || name.contains(">") || name.contains("&") || name.contains("\\") || name.contains("\"") || name.contains("$"))
{
activeChar.sendMessage("You cannot use symbols like: < > & \" $ \\");
return;
}
_zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder()).setName(name);
}
/**
* @param activeChar
*/
private void enablePicking(L2PcInstance activeChar)
{
if (!activeChar.hasAction(PlayerAction.ADMIN_POINT_PICKING))
{
activeChar.addAction(PlayerAction.ADMIN_POINT_PICKING);
activeChar.sendMessage("Point picking mode activated!");
}
else
{
activeChar.sendMessage("Point picking mode is already activated!");
}
}
/**
* @param activeChar
*/
private void disablePicking(L2PcInstance activeChar)
{
if (activeChar.removeAction(PlayerAction.ADMIN_POINT_PICKING))
{
activeChar.sendMessage("Point picking mode deactivated!");
}
else
{
activeChar.sendMessage("Point picking mode was not activated!");
}
}
/**
* @param activeChar
*/
private void showPoints(L2PcInstance activeChar)
{
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
if (holder != null)
{
if (holder.getNodes().size() < 3)
{
activeChar.sendMessage("In order to visualize this zone you must have at least 3 points.");
return;
}
final ExServerPrimitive exsp = new ExServerPrimitive("DebugPoint_" + activeChar.getObjectId(), activeChar.getX(), activeChar.getY(), activeChar.getZ());
int index = 1;
for (Location loc : holder.getNodes())
{
exsp.addPoint("Point: " + index, Color.GREEN, true, loc);
index++;
}
final List<Location> list = holder.getNodes();
for (int i = 1; i < list.size(); i++)
{
final Location prevLoc = list.get(i - 1);
final Location nextLoc = list.get(i);
exsp.addLine("Point " + i + " > " + (i + 1), Color.WHITE, true, prevLoc, nextLoc);
}
exsp.addLine("Point " + list.size() + " > 1", Color.WHITE, true, list.get(list.size() - 1), list.get(0));
activeChar.sendPacket(exsp);
}
}
/**
* @param activeChar
* @param index
*/
private void changePoint(L2PcInstance activeChar, int index)
{
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
if (holder != null)
{
final Location loc = holder.getNodes().get(index);
if (loc != null)
{
enablePicking(activeChar);
holder.setChangingLoc(loc);
}
}
}
/**
* @param activeChar
* @param index
*/
private void deletePoint(L2PcInstance activeChar, int index)
{
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
if (holder != null)
{
final Location loc = holder.getNodes().get(index);
if (loc != null)
{
holder.getNodes().remove(loc);
activeChar.sendMessage("Node " + index + " has been removed!");
if (holder.getNodes().isEmpty())
{
activeChar.sendMessage("Since node list is empty destroying session!");
_zones.remove(activeChar.getObjectId());
}
}
}
}
/**
* @param activeChar
*/
private void dumpPoints(final L2PcInstance activeChar)
{
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
if ((holder != null) && !holder.getNodes().isEmpty())
{
if (holder.getName().isEmpty())
{
activeChar.sendMessage("Set name first!");
return;
}
final Location firstNode = holder.getNodes().get(0);
final StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Config.EOL);
sb.append("<list enabled=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"../../../data/xsd/zones.xsd\">" + Config.EOL);
sb.append("\t<zone name=\"" + holder.getName() + "\" type=\"ScriptZone\" shape=\"NPoly\" minZ=\"" + (firstNode.getZ() - 100) + "\" maxZ=\"" + (firstNode.getZ() + 100) + "\">" + Config.EOL);
for (Location loc : holder.getNodes())
{
sb.append("\t\t<node X=\"" + loc.getX() + "\" Y=\"" + loc.getY() + "\" />" + Config.EOL);
}
sb.append("\t</zone>" + Config.EOL);
sb.append("</list>" + Config.EOL);
try
{
File file = new File(Config.DATAPACK_ROOT, "log/points/" + activeChar.getAccountName() + "/" + holder.getName() + ".xml");
if (file.exists())
{
int i = 0;
while ((file = new File(Config.DATAPACK_ROOT, "log/points/" + activeChar.getAccountName() + "/" + holder.getName() + i + ".xml")).exists())
{
i++;
}
}
if (!file.getParentFile().isDirectory())
{
file.getParentFile().mkdirs();
}
Files.write(file.toPath(), sb.toString().getBytes(StandardCharsets.UTF_8));
activeChar.sendMessage("Successfully written on: " + file.getAbsolutePath().replace(Config.DATAPACK_ROOT.getAbsolutePath(), ""));
}
catch (Exception e)
{
activeChar.sendMessage("Failed writing the dump: " + e.getMessage());
_log.log(Level.WARNING, "Failed writing point picking dump for " + activeChar.getName() + ":" + e.getMessage(), e);
}
}
}
@RegisterEvent(EventType.ON_PLAYER_MOVE_REQUEST)
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
@Priority(Integer.MAX_VALUE)
public TerminateReturn onPlayerPointPicking(OnPlayerMoveRequest event)
{
final L2PcInstance activeChar = event.getActiveChar();
if (activeChar.hasAction(PlayerAction.ADMIN_POINT_PICKING))
{
final Location newLocation = event.getLocation();
final ZoneNodeHolder holder = _zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder());
final Location changeLog = holder.getChangingLoc();
if (changeLog != null)
{
changeLog.setXYZ(newLocation);
holder.setChangingLoc(null);
activeChar.sendMessage("Location " + (holder.indexOf(changeLog) + 1) + " has been updated!");
disablePicking(activeChar);
}
else
{
holder.addNode(newLocation);
activeChar.sendMessage("Location " + (holder.indexOf(changeLog) + 1) + " has been added!");
}
// Auto visualization when nodes >= 3
if (holder.getNodes().size() >= 3)
{
showPoints(activeChar);
}
buildHtmlWindow(activeChar, 0);
return new TerminateReturn(true, true, false);
}
return null;
}
@RegisterEvent(EventType.ON_PLAYER_DLG_ANSWER)
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
public void onPlayerDlgAnswer(OnPlayerDlgAnswer event)
{
final L2PcInstance activeChar = event.getActiveChar();
if (activeChar.removeAction(PlayerAction.ADMIN_SHOW_TERRITORY) && (event.getAnswer() == 1))
{
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
if (holder != null)
{
final List<Location> list = holder.getNodes();
if (list.size() < 3)
{
activeChar.sendMessage("You must have at least 3 nodes to use this option!");
return;
}
final Location firstLoc = list.get(0);
final ExShowTerritory exst = new ExShowTerritory(firstLoc.getZ() - 100, firstLoc.getZ() + 100);
list.forEach(exst::addVertice);
activeChar.sendPacket(exst);
activeChar.sendMessage("In order to remove the debug you must restart your game client!");
}
}
}
@Override
public String[] getAdminCommandList()
{
return COMMANDS;
}
private void buildHtmlWindow(final L2PcInstance activeChar, final int page)
{
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/zone_editor_create.htm");
final ZoneNodeHolder holder = _zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder());
final AtomicInteger position = new AtomicInteger(page * 20);
final PageResult result = HtmlUtil.createPage(holder.getNodes(), page, 20, i ->
{
return "<td align=center><button action=\"bypass -h admin_zones list " + i + "\" value=\"" + (i + 1) + "\" width=30 height=22 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>";
}, loc ->
{
final StringBuilder sb = new StringBuilder();
sb.append("<tr>");
sb.append("<td fixwidth=5></td>");
sb.append("<td fixwidth=20>" + position.getAndIncrement() + "</td>");
sb.append("<td fixwidth=60>" + loc.getX() + "</td>");
sb.append("<td fixwidth=60>" + loc.getY() + "</td>");
sb.append("<td fixwidth=60>" + loc.getZ() + "</td>");
sb.append("<td fixwidth=30><a action=\"bypass -h admin_zones change " + holder.indexOf(loc) + "\">[E]</a></td>");
sb.append("<td fixwidth=30><a action=\"bypass -h admin_move_to " + loc.getX() + " " + loc.getY() + " " + loc.getZ() + "\">[T]</a></td>");
sb.append("<td fixwidth=30><a action=\"bypass -h admin_zones delete " + holder.indexOf(loc) + "\">[D]</a></td>");
sb.append("<td fixwidth=5></td>");
sb.append("</tr>");
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<Location> _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<Location> getNodes()
{
return _nodes;
}
public int indexOf(Location loc)
{
return _nodes.indexOf(loc);
}
}
}

View File

@@ -175,17 +175,7 @@ public class QuestLink implements IBypassHandler
} }
else else
{ {
int questId = quest.getId(); StringUtil.append(sb, "<fstring>", String.valueOf(quest.getNpcStringId()), state, "</fstring>");
if (questId > 10000)
{
questId -= 5000;
}
else if (questId == 146)
{
questId = 640;
}
StringUtil.append(sb, "<fstring>", String.valueOf(questId), state, "</fstring>");
} }
sb.append("</button></font>"); sb.append("</button></font>");
} }

View File

@@ -46,6 +46,12 @@ public class Q00146_TheZeroHour extends Quest
registerQuestItems(FANG); registerQuestItems(FANG);
} }
@Override
public int getNpcStringId()
{
return 640;
}
@Override @Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{ {

View File

@@ -17,6 +17,7 @@
package com.l2jmobius.gameserver.engines.items; package com.l2jmobius.gameserver.engines.items;
import java.io.File; import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -106,7 +107,7 @@ public final class DocumentItem extends DocumentBase
_currentItem.set.set("name", itemName); _currentItem.set.set("name", itemName);
_currentItem.set.set("additionalName", additionalName); _currentItem.set.set("additionalName", additionalName);
final Node first = n.getFirstChild(); Node first = n.getFirstChild();
for (n = first; n != null; n = n.getNextSibling()) for (n = first; n != null; n = n.getNextSibling())
{ {
if ("table".equalsIgnoreCase(n.getNodeName())) if ("table".equalsIgnoreCase(n.getNodeName()))
@@ -133,9 +134,9 @@ public final class DocumentItem extends DocumentBase
else if ("cond".equalsIgnoreCase(n.getNodeName())) else if ("cond".equalsIgnoreCase(n.getNodeName()))
{ {
makeItem(); makeItem();
final Condition condition = parseCondition(n.getFirstChild(), _currentItem.item); Condition condition = parseCondition(n.getFirstChild(), _currentItem.item);
final Node msg = n.getAttributes().getNamedItem("msg"); Node msg = n.getAttributes().getNamedItem("msg");
final Node msgId = n.getAttributes().getNamedItem("msgId"); Node msgId = n.getAttributes().getNamedItem("msgId");
if ((condition != null) && (msg != null)) if ((condition != null) && (msg != null))
{ {
condition.setMessage(msg.getNodeValue()); condition.setMessage(msg.getNodeValue());
@@ -143,7 +144,8 @@ public final class DocumentItem extends DocumentBase
else if ((condition != null) && (msgId != null)) else if ((condition != null) && (msgId != null))
{ {
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null))); condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0)) Node addName = n.getAttributes().getNamedItem("addName");
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
{ {
condition.addName(); condition.addName();
} }
@@ -157,13 +159,17 @@ public final class DocumentItem extends DocumentBase
private void makeItem() throws InvocationTargetException private void makeItem() throws InvocationTargetException
{ {
// If item exists just reload the data.
if (_currentItem.item != null) if (_currentItem.item != null)
{ {
return; // item is already created _currentItem.item.set(_currentItem.set);
return;
} }
try try
{ {
_currentItem.item = (L2Item) Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class).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) catch (Exception e)
{ {

View File

@@ -22,6 +22,8 @@ package com.l2jmobius.gameserver.enums;
public enum PlayerAction public enum PlayerAction
{ {
ADMIN_COMMAND, ADMIN_COMMAND,
ADMIN_POINT_PICKING,
ADMIN_SHOW_TERRITORY,
USER_ENGAGE; USER_ENGAGE;
private final int _mask; private final int _mask;

View File

@@ -47,7 +47,11 @@ public final class QuestManager
public boolean reload(String questFolder) public boolean reload(String questFolder)
{ {
final Quest q = getQuest(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) public boolean reload(int questId)
{ {
final Quest q = getQuest(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() public void save()
{ {
// Save quests. // Save quests.
for (Quest quest : _quests.values()) for (Quest quest : _quests.values())
{ {
quest.saveGlobalData(); quest.onSave();
} }
// Save scripts. // Save scripts.
for (Quest script : _scripts.values()) for (Quest script : _scripts.values())
{ {
script.saveGlobalData(); script.onSave();
} }
} }
@@ -135,7 +143,11 @@ public final class QuestManager
*/ */
public Quest getQuest(String name) 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);
} }
/** /**
@@ -180,11 +192,13 @@ public final class QuestManager
{ {
old.unload(); old.unload();
_log.info(getClass().getSimpleName() + ": Replaced quest " + old.getName() + " (" + old.getId() + ") with a new version!"); _log.info(getClass().getSimpleName() + ": Replaced quest " + old.getName() + " (" + old.getId() + ") with a new version!");
} }
if (Config.ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS) 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 +229,7 @@ public final class QuestManager
public boolean unload(Quest ms) public boolean unload(Quest ms)
{ {
ms.saveGlobalData(); ms.onSave();
return removeScript(ms); return removeScript(ms);
} }

View File

@@ -62,6 +62,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.OnPlayerLevelChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin; 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.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.OnPlayerPKChanged;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionChange; import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerProfessionChange;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPChanged; import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerPvPChanged;
@@ -221,6 +222,7 @@ public enum EventType
ON_PLAYER_LOGIN(OnPlayerLogin.class, void.class), ON_PLAYER_LOGIN(OnPlayerLogin.class, void.class),
ON_PLAYER_LOGOUT(OnPlayerLogout.class, void.class), ON_PLAYER_LOGOUT(OnPlayerLogout.class, void.class),
ON_PLAYER_PK_CHANGED(OnPlayerPKChanged.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_PROFESSION_CHANGE(OnPlayerProfessionChange.class, void.class),
ON_PLAYER_CHANGE_TO_AWAKENED_CLASS(OnPlayerChangeToAwakenedClass.class, void.class), ON_PLAYER_CHANGE_TO_AWAKENED_CLASS(OnPlayerChangeToAwakenedClass.class, void.class),
ON_PLAYER_PVP_CHANGED(OnPlayerPvPChanged.class, void.class), ON_PLAYER_PVP_CHANGED(OnPlayerPvPChanged.class, void.class),

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@@ -40,6 +40,12 @@ public final class L2Armor extends L2Item
public L2Armor(StatsSet set) public L2Armor(StatsSet set)
{ {
super(set); super(set);
}
@Override
public void set(StatsSet set)
{
super.set(set);
_type = set.getEnum("armor_type", ArmorType.class, ArmorType.NONE); _type = set.getEnum("armor_type", ArmorType.class, ArmorType.NONE);
final int _bodyPart = getBodyPart(); final int _bodyPart = getBodyPart();

View File

@@ -32,11 +32,11 @@ public final class L2EtcItem extends L2Item
{ {
private String _handler; private String _handler;
private EtcItemType _type; private EtcItemType _type;
private final boolean _isBlessed; private boolean _isBlessed;
private final List<L2ExtractableProduct> _extractableItems; private List<L2ExtractableProduct> _extractableItems;
private final int _extractableCountMin; private int _extractableCountMin;
private final int _extractableCountMax; private int _extractableCountMax;
private final boolean _isInfinite; private boolean _isInfinite;
/** /**
* Constructor for EtcItem. * Constructor for EtcItem.
@@ -45,6 +45,12 @@ public final class L2EtcItem extends L2Item
public L2EtcItem(StatsSet set) public L2EtcItem(StatsSet set)
{ {
super(set); super(set);
}
@Override
public void set(StatsSet set)
{
super.set(set);
_type = set.getEnum("etcitem_type", EtcItemType.class, EtcItemType.NONE); _type = set.getEnum("etcitem_type", EtcItemType.class, EtcItemType.NONE);
// l2j custom - L2EtcItemType.SHOT // l2j custom - L2EtcItemType.SHOT

View File

@@ -112,43 +112,43 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
public static final int SLOT_MULTI_ALLWEAPON = SLOT_LR_HAND | SLOT_R_HAND; public static final int SLOT_MULTI_ALLWEAPON = SLOT_LR_HAND | SLOT_R_HAND;
private final int _itemId; private int _itemId;
private final int _displayId; private int _displayId;
private final String _name; private String _name;
private final String _additionalName; private String _additionalName;
private final String _icon; private String _icon;
private final int _weight; private int _weight;
private final boolean _stackable; private boolean _stackable;
private final MaterialType _materialType; private MaterialType _materialType;
private final CrystalType _crystalType; private CrystalType _crystalType;
private final int _equipReuseDelay; private int _equipReuseDelay;
private final int _duration; private int _duration;
private final int _time; private int _time;
private final int _autoDestroyTime; private int _autoDestroyTime;
private final int _bodyPart; private int _bodyPart;
private final int _referencePrice; private int _referencePrice;
private final int _crystalCount; private int _crystalCount;
private final boolean _sellable; private boolean _sellable;
private final boolean _dropable; private boolean _dropable;
private final boolean _destroyable; private boolean _destroyable;
private final boolean _tradeable; private boolean _tradeable;
private final boolean _depositable; private boolean _depositable;
private final boolean _auctionable; private boolean _auctionable;
private final int _enchantable; private int _enchantable;
private final boolean _elementable; private boolean _elementable;
private final boolean _questItem; private boolean _questItem;
private final boolean _freightable; private boolean _freightable;
private final boolean _allow_self_resurrection; private boolean _allow_self_resurrection;
private final boolean _is_oly_restricted; private boolean _is_oly_restricted;
private final boolean _for_npc; private boolean _for_npc;
private final boolean _common; private boolean _common;
private final boolean _heroItem; private boolean _heroItem;
private final boolean _pvpItem; private boolean _pvpItem;
private final boolean _immediate_effect; private boolean _immediate_effect;
private final boolean _ex_immediate_effect; private boolean _ex_immediate_effect;
private final int _defaultEnchantLevel; private int _defaultEnchantLevel;
private final ActionType _defaultAction; private ActionType _defaultAction;
private final boolean _isBlessedItem; private boolean _isBlessedItem;
protected int _type1; // needed for item list (inventory) protected int _type1; // needed for item list (inventory)
protected int _type2; // different lists for armor, weapon, etc protected int _type2; // different lists for armor, weapon, etc
@@ -159,13 +159,13 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
private SkillHolder _unequipSkill = null; private SkillHolder _unequipSkill = null;
private SkillHolder _equipSkill = null; private SkillHolder _equipSkill = null;
private final int _useSkillDisTime; private int _useSkillDisTime;
private final int _reuseDelay; private int _reuseDelay;
private final int _sharedReuseGroup; private int _sharedReuseGroup;
private final CommissionItemType _commissionItemType; private CommissionItemType _commissionItemType;
private final int _compoundItem; private int _compoundItem;
private final float _compoundChance; private float _compoundChance;
/** /**
* Constructor of the L2Item that fill class variables.<BR> * Constructor of the L2Item that fill class variables.<BR>
@@ -173,6 +173,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 * @param set : StatsSet corresponding to a set of couples (key,value) for description of the item
*/ */
protected L2Item(StatsSet set) protected L2Item(StatsSet set)
{
set(set);
}
public void set(StatsSet set)
{ {
_itemId = set.getInt("item_id"); _itemId = set.getInt("item_id");
_displayId = set.getInt("displayId", _itemId); _displayId = set.getInt("displayId", _itemId);

View File

@@ -40,19 +40,19 @@ import com.l2jmobius.util.StringUtil;
*/ */
public final class L2Weapon extends L2Item public final class L2Weapon extends L2Item
{ {
private final WeaponType _type; private WeaponType _type;
private final boolean _isMagicWeapon; private boolean _isMagicWeapon;
private final int _rndDam; private int _rndDam;
private final int _soulShotCount; private int _soulShotCount;
private final int _spiritShotCount; private int _spiritShotCount;
private final int _mpConsume; private int _mpConsume;
private final int _baseAttackRange; private int _baseAttackRange;
private final int _baseAttackAngle; private int _baseAttackAngle;
/** /**
* Skill that activates when item is enchanted +4 (for duals). * Skill that activates when item is enchanted +4 (for duals).
*/ */
private SkillHolder _enchant4Skill = null; private SkillHolder _enchant4Skill = null;
private final int _changeWeaponId; private int _changeWeaponId;
// Attached skills for Special Abilities // Attached skills for Special Abilities
private SkillHolder _skillsOnMagic; private SkillHolder _skillsOnMagic;
@@ -60,15 +60,15 @@ public final class L2Weapon extends L2Item
private SkillHolder _skillsOnCrit; private SkillHolder _skillsOnCrit;
private Condition _skillsOnCritCondition = null; private Condition _skillsOnCritCondition = null;
private final int _reducedSoulshot; private int _reducedSoulshot;
private final int _reducedSoulshotChance; private int _reducedSoulshotChance;
private final int _reducedMpConsume; private int _reducedMpConsume;
private final int _reducedMpConsumeChance; private int _reducedMpConsumeChance;
private final boolean _isForceEquip; private boolean _isForceEquip;
private final boolean _isAttackWeapon; private boolean _isAttackWeapon;
private final boolean _useWeaponSkillsOnly; private boolean _useWeaponSkillsOnly;
/** /**
* Constructor for Weapon. * Constructor for Weapon.
@@ -77,6 +77,12 @@ public final class L2Weapon extends L2Item
public L2Weapon(StatsSet set) public L2Weapon(StatsSet set)
{ {
super(set); super(set);
}
@Override
public void set(StatsSet set)
{
super.set(set);
_type = WeaponType.valueOf(set.getString("weapon_type", "none").toUpperCase()); _type = WeaponType.valueOf(set.getString("weapon_type", "none").toUpperCase());
_type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE; _type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE;
_type2 = L2Item.TYPE2_WEAPON; _type2 = L2Item.TYPE2_WEAPON;

View File

@@ -125,7 +125,7 @@ public class Quest extends AbstractScript implements IIdentifiable
QuestManager.getInstance().addScript(this); QuestManager.getInstance().addScript(this);
} }
loadGlobalData(); onLoad();
} }
/** /**
@@ -151,17 +151,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.<br> * Children of this class can implement this function in order to define what variables to load and what structures to save them in.<br>
* By default, nothing is loaded. * 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.<br> * The function onSave is, by default, called at shutdown, for all quests, by the QuestManager.<br>
* Children of this class can implement this function in order to convert their structures<br> * Children of this class can implement this function in order to convert their structures<br>
* into <var, value> tuples and make calls to save them to the database, if needed.<br> * into <var, value> tuples and make calls to save them to the database, if needed.<br>
* By default, nothing is saved. * By default, nothing is saved.
*/ */
public void saveGlobalData() public void onSave()
{ {
} }
@@ -175,6 +175,14 @@ public class Quest extends AbstractScript implements IIdentifiable
return _questId; 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. * Add a new quest state of this quest to the database.
* @param player the owner of the newly created quest state * @param player the owner of the newly created quest state
@@ -2679,7 +2687,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/ */
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
saveGlobalData(); onSave();
// cancel all pending timers before reloading. // cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // 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). // with its code (example: save global data indicating what timer must be restarted).

View File

@@ -134,4 +134,14 @@ public class ZoneNPoly extends L2ZoneForm
GeoData.getInstance().getHeight(x, y, _z1) GeoData.getInstance().getHeight(x, y, _z1)
}; };
} }
public int[] getX()
{
return _p.xpoints;
}
public int[] getY()
{
return _p.ypoints;
}
} }

View File

@@ -24,6 +24,9 @@ import com.l2jmobius.gameserver.instancemanager.JumpManager;
import com.l2jmobius.gameserver.instancemanager.JumpManager.JumpWay; import com.l2jmobius.gameserver.instancemanager.JumpManager.JumpWay;
import com.l2jmobius.gameserver.model.Location; import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; 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.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed; import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.ExFlyMove; import com.l2jmobius.gameserver.network.serverpackets.ExFlyMove;
@@ -46,7 +49,6 @@ public class MoveBackwardToLocation extends L2GameClientPacket
private int _originY; private int _originY;
private int _originZ; private int _originZ;
@SuppressWarnings("unused")
private int _moveMovement; private int _moveMovement;
@Override @Override
@@ -102,6 +104,16 @@ public class MoveBackwardToLocation extends L2GameClientPacket
// Validate position packets sends head level. // Validate position packets sends head level.
_targetZ += activeChar.getTemplate().getCollisionHeight(); _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() > 0)
{ {
// Sayune // Sayune

View File

@@ -106,6 +106,11 @@ public abstract class AbstractHtmlPacket extends L2GameServerPacket
_html = _html.replaceAll(pattern, value.replaceAll("\\$", "\\\\\\$")); _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) public final void replace(String pattern, boolean val)
{ {
replace(pattern, String.valueOf(val)); replace(pattern, String.valueOf(val));

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.interfaces.ILocational;
/**
* Note: <b>There is known issue with this packet, it cannot be removed unless game client is restarted!</b>
* @author UnAfraid
*/
public class ExShowTerritory extends L2GameServerPacket
{
private final int _minZ;
private final int _maxZ;
private final List<ILocational> _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());
}
}
}

View File

@@ -21,6 +21,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@@ -29,6 +30,7 @@ import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -170,7 +172,7 @@ public final class ScriptEngineManager
checkExistingFile("ScriptList", SCRIPT_LIST_FILE); checkExistingFile("ScriptList", SCRIPT_LIST_FILE);
final Map<IExecutionContext, List<Path>> files = new LinkedHashMap<>(); final Map<IExecutionContext, List<Path>> files = new LinkedHashMap<>();
final List<String> extWithoutEngine = new LinkedList<>(); final Set<String> extWithoutEngine = new HashSet<>();
Files.lines(SCRIPT_LIST_FILE).forEach(line -> Files.lines(SCRIPT_LIST_FILE).forEach(line ->
{ {
@@ -202,21 +204,14 @@ public final class ScriptEngineManager
final IExecutionContext engine = getEngineByExtension(ext); final IExecutionContext engine = getEngineByExtension(ext);
if (engine == null) if (engine == null)
{ {
if (!extWithoutEngine.contains(ext)) if (extWithoutEngine.add(ext))
{ {
extWithoutEngine.add(ext);
_log.warning("ScriptEngine: No engine registered for extension " + ext + "!"); _log.warning("ScriptEngine: No engine registered for extension " + ext + "!");
} }
return; return;
} }
List<Path> ll = files.get(engine); files.computeIfAbsent(engine, k -> new LinkedList<>()).add(sourceFile);
if (ll == null)
{
ll = new LinkedList<>();
files.put(engine, ll);
}
ll.add(sourceFile);
}); });
for (Entry<IExecutionContext, List<Path>> entry : files.entrySet()) for (Entry<IExecutionContext, List<Path>> entry : files.entrySet())

View File

@@ -23,6 +23,7 @@ import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -99,8 +100,6 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
try (final ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8))) try (final ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8)))
{ {
final StringWriter strOut = new StringWriter();
final PrintWriter out = new PrintWriter(strOut);
final LinkedList<String> options = new LinkedList<>(); final LinkedList<String> options = new LinkedList<>();
addOptionIfNotNull(options, getProperty("source"), "-source"); addOptionIfNotNull(options, getProperty("source"), "-source");
@@ -133,12 +132,14 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
} }
// we really need an iterable of files or strings // we really need an iterable of files or strings
final LinkedList<String> sourcePathStrings = new LinkedList<>(); final List<String> sourcePathStrings = new LinkedList<>();
for (Path sourcePath : sourcePaths) for (Path sourcePath : sourcePaths)
{ {
sourcePathStrings.add(sourcePath.toString()); 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(); final boolean compilationSuccess = getScriptingEngine().getCompiler().getTask(out, fileManager, compilationDiagnostics, options, null, fileManager.getJavaFileObjectsFromStrings(sourcePathStrings)).call();
if (!compilationSuccess) if (!compilationSuccess)
{ {
@@ -169,8 +170,8 @@ public final class JavaExecutionContext extends AbstractExecutionContext<JavaScr
final ClassLoader parentClassLoader = determineScriptParentClassloader(); final ClassLoader parentClassLoader = determineScriptParentClassloader();
LinkedHashMap<Path, Throwable> executionFailures = new LinkedHashMap<>(); final Map<Path, Throwable> executionFailures = new LinkedHashMap<>();
Iterable<ScriptingOutputFileObject> compiledClasses = fileManager.getCompiledClasses(); final Iterable<ScriptingOutputFileObject> compiledClasses = fileManager.getCompiledClasses();
for (final Path sourcePath : sourcePaths) for (final Path sourcePath : sourcePaths)
{ {
boolean found = false; boolean found = false;