list : quest.getQuestTimers().values())
{
for (QuestTimer timer : list)
{
timers += "" + timer.getName() + ": Active: " + timer.getIsActive() + " Repeatable: " + timer.getIsRepeating() + " Player: " + timer.getPlayer() + " Npc: " + timer.getNpc() + " |
|
";
counter++;
if (counter > 10)
{
break;
}
}
}
final StringBuilder sb = new StringBuilder();
sb.append("ID: " + quest.getId() + " |
|
");
sb.append("Name: " + quest.getName() + " |
|
");
sb.append("Path: " + quest.getPath() + " |
|
");
sb.append(" |
");
if (!npcs.isEmpty())
{
sb.append(" |
");
}
if (!items.isEmpty())
{
sb.append(" |
");
}
if (!timers.isEmpty())
{
sb.append(" |
");
sb.append(timers);
}
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npc-quests.htm");
msg.replace("%quests%", sb.toString());
msg.replace("%questName%", "");
activeChar.sendPacket(msg);
}
return true;
}
private void showDir(String dir, L2PcInstance activeChar)
{
String replace = null;
File path;
String currentPath = "/";
if ((dir == null) || dir.trim().isEmpty() || dir.contains(".."))
{
final StringBuilder sb = new StringBuilder(200);
path = ScriptEngineManager.SCRIPT_FOLDER.toFile();
final String[] children = path.list();
Arrays.sort(children);
for (String c : children)
{
final File n = new File(path, c);
if (n.isHidden() || n.getName().startsWith("."))
{
continue;
}
else if (n.isDirectory())
{
sb.append("" + c + "");
}
else if (c.endsWith(".java") || c.endsWith(".py"))
{
sb.append("" + c + "");
}
}
replace = sb.toString();
}
else
{
path = new File(ScriptEngineManager.SCRIPT_FOLDER.toFile(), dir);
if (!path.isDirectory())
{
activeChar.sendMessage("Wrong path.");
return;
}
currentPath = dir;
final boolean questReducedNames = currentPath.equalsIgnoreCase("quests");
final StringBuilder sb = new StringBuilder(200);
sb.append("..");
final String[] children = path.list();
Arrays.sort(children);
for (String c : children)
{
final File n = new File(path, c);
if (n.isHidden() || n.getName().startsWith("."))
{
continue;
}
else if (n.isDirectory())
{
sb.append("" + (questReducedNames ? getQuestName(c) : c) + "");
}
else if (c.endsWith(".java") || c.endsWith(".py"))
{
sb.append("" + c + "");
}
}
replace = sb.toString();
if (questReducedNames)
{
currentPath += " (limited list - HTML too long)";
}
}
if (replace.length() > 17200)
{
replace = replace.substring(0, 17200); // packetlimit
}
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/scriptdirectory.htm");
html.replace("%path%", currentPath);
html.replace("%list%", replace);
activeChar.sendPacket(html);
}
private String getUpPath(String full)
{
final int index = full.lastIndexOf("/");
if (index == -1)
{
return "";
}
return full.substring(0, index);
}
private String getQuestName(String full)
{
return full.split("_")[0];
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}