actual freya branch

This commit is contained in:
2026-09-12 15:41:31 +00:00
parent 8049e0a882
commit 68c1cd27d4
3510 changed files with 336689 additions and 302906 deletions
@@ -0,0 +1,71 @@
/*
* 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/>.
*/
/**
coded by Balancer
balancer@balancer.ru
http://balancer.ru
version 0.1, 2005-06-06
*/
package com.l2jserver.util.lib;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Log
{
private static final Logger _log = Logger.getLogger(Log.class.getName());
public static final void add(String text, String cat)
{
/*
* Logger _log = logs.get(cat); if(_log == null) { _log = Logger.getLogger(cat); logs.put(cat, _log); }
*/
String date = (new SimpleDateFormat("yy.MM.dd H:mm:ss")).format(new Date());
String curr = (new SimpleDateFormat("yyyy-MM-dd-")).format(new Date());
new File("log/game").mkdirs();
FileWriter save = null;
try
{
File file = new File("log/game/" + (curr != null ? curr : "") + (cat != null ? cat : "unk") + ".txt");
save = new FileWriter(file, true);
String out = "[" + date + "] " + text + "\n";
save.write(out);
}
catch (IOException e)
{
_log.log(Level.WARNING, "Error saving logfile: ", e);
}
finally
{
try
{
save.close();
}
catch (Exception e)
{
}
}
}
}
@@ -0,0 +1,190 @@
/*
* 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.l2jserver.util.lib;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
public class SqlUtils
{
private static Logger _log = Logger.getLogger(SqlUtils.class.getName());
private SqlUtils()
{
}
// =========================================================
// Property - Public
public static SqlUtils getInstance()
{
return SingletonHolder._instance;
}
// =========================================================
// Method - Public
public static Integer getIntValue(String resultField, String tableName, String whereClause)
{
String query = "";
Integer res = null;
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
query = L2DatabaseFactory.getInstance().prepQuerySelect(new String[]
{
resultField
}, tableName, whereClause, true);
PreparedStatement statement = con.prepareStatement(query);
ResultSet rset = statement.executeQuery();
if (rset.next())
{
res = rset.getInt(1);
}
rset.close();
statement.close();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error in query '" + query + "':", e);
}
finally
{
L2DatabaseFactory.close(con);
}
return res;
}
public static Integer[] getIntArray(String resultField, String tableName, String whereClause)
{
String query = "";
Integer[] res = null;
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
query = L2DatabaseFactory.getInstance().prepQuerySelect(new String[]
{
resultField
}, tableName, whereClause, false);
PreparedStatement statement = con.prepareStatement(query);
ResultSet rset = statement.executeQuery();
int rows = 0;
while (rset.next())
{
rows++;
}
if (rows == 0)
{
return new Integer[0];
}
res = new Integer[rows - 1];
rset.first();
int row = 0;
while (rset.next())
{
res[row] = rset.getInt(1);
}
rset.close();
statement.close();
}
catch (Exception e)
{
_log.log(Level.WARNING, "mSGI: Error in query '" + query + "':", e);
}
finally
{
L2DatabaseFactory.close(con);
}
return res;
}
public static Integer[][] get2DIntArray(String[] resultFields, String usedTables, String whereClause)
{
long start = System.currentTimeMillis();
String query = "";
Connection con = null;
Integer res[][] = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
query = L2DatabaseFactory.getInstance().prepQuerySelect(resultFields, usedTables, whereClause, false);
PreparedStatement statement = con.prepareStatement(query);
ResultSet rset = statement.executeQuery();
int rows = 0;
while (rset.next())
{
rows++;
}
res = new Integer[rows - 1][resultFields.length];
rset.first();
int row = 0;
while (rset.next())
{
for (int i = 0; i < resultFields.length; i++)
{
res[row][i] = rset.getInt(i + 1);
}
row++;
}
rset.close();
statement.close();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error in query '" + query + "':", e);
}
finally
{
L2DatabaseFactory.close(con);
}
_log.fine("Get all rows in query '" + query + "' in " + (System.currentTimeMillis() - start) + "ms");
return res;
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final SqlUtils _instance = new SqlUtils();
}
}