/
tofu
/
l2interlude
Обзор
Документация
Войти
/
tofu
/
l2interlude
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/main/java/com/l2jserver/gameserver/script/ScriptPackage.java
103 строки
3 KB
Zoey76
Copyright Update
01 янв 2025, 07:57
01 янв 2025, 07:57
16130a5
Код
Авторство
О чём код?
/* * Copyright © 2004-2025 L2J Server * * This file is part of L2J Server. * * L2J Server 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. * * L2J Server 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.l2jserver.gameserver.script; import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.l2jserver.gameserver.config.Configuration; /** * @author Luis Arias */ public class ScriptPackage { private static final Logger LOG = LoggerFactory.getLogger(ScriptPackage.class); private final List<ScriptDocument> _scriptFiles = new ArrayList<>(); private final List<String> _otherFiles = new ArrayList<>(); private final String _name; public ScriptPackage(ZipFile pack) { _name = pack.getName(); addFiles(pack); } public List<String> getOtherFiles() { return _otherFiles; } public List<ScriptDocument> getScriptFiles() { return _scriptFiles; } private void addFiles(ZipFile pack) { for (Enumeration<? extends ZipEntry> e = pack.entries(); e.hasMoreElements();) { ZipEntry entry = e.nextElement(); if (entry.getName().endsWith(".xml")) { try { _scriptFiles.add(new ScriptDocument(entry.getName(), pack.getInputStream(entry))); } catch (IOException io) { LOG.warn(io.getMessage(), io); } } else if (!entry.isDirectory()) { _otherFiles.add(entry.getName()); } } } public String getName() { return _name; } @Override public String toString() { if (getScriptFiles().isEmpty() && getOtherFiles().isEmpty()) { return "Empty Package."; } StringBuilder out = new StringBuilder(); out.append("package Name: "); out.append(getName()); out.append(Configuration.EOL); if (!getScriptFiles().isEmpty()) { out.append("Xml Script Files...").append(Configuration.EOL); for (ScriptDocument script : getScriptFiles()) { out.append(script.getName()); out.append(Configuration.EOL); } } if (!getOtherFiles().isEmpty()) { out.append("Other Files...").append(Configuration.EOL); for (String fileName : getOtherFiles()) { out.append(fileName); out.append(Configuration.EOL); } } return out.toString(); } }