/* 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 2, 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package com.l2jfrozen.gameserver.model.entity;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.logging.Logger;
import com.l2jfrozen.util.database.L2DatabaseFactory;
import com.l2jfrozen.gameserver.model.entity.Announcements;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;
/**
*
* @author Fanky
*/
public class PvpLordTask
{
static String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
protected static final Logger _log = Logger.getLogger(PvpLordTask.class.getName());
public static void getInstance()
{
ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
{
public void run()
{
String currentPvpLord = null,
newPvpLord = null;
int topTodayPvps = 0;
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement stm = con.prepareStatement("SELECT char_name FROM characters WHERE pvplord=? AND accesslevel=?");
stm.setInt(1, 1);
stm.setInt(2, 0);
ResultSet rSet = stm.executeQuery();
if (rSet.next())
{
currentPvpLord = rSet.getString("char_name");
}
rSet.close();
stm.close();
if (currentPvpLord != null)
{
boolean cont = false;
L2PcInstance cPvpLord = L2World.getInstance().getPlayer(currentPvpLord);
if (cPvpLord == null || cPvpLord.isOnline() == 0)
{
cont = true;
}
else
{
cPvpLord.setPvpLord(false);
cPvpLord.setIsHero(false);
cPvpLord.getAppearance().setNameColor(0xFFFFFF);
cPvpLord.broadcastUserInfo();
}
if (cont)
{
stm = con.prepareStatement("UPDATE characters SET pvplord=? WHERE char_name=?");
stm.setInt(1, 0);
stm.setString(2, currentPvpLord);
stm.execute();
stm.close();
}
}
stm = con.prepareStatement("SELECT todaypvps,char_name FROM characters WHERE accesslevel=? ORDER BY todaypvps DESC LIMIT 1");
stm.setInt(1, 0);
rSet = stm.executeQuery();
if (rSet.next())
{
newPvpLord = rSet.getString("char_name");
topTodayPvps = rSet.getInt("todaypvps");
}
rSet.close();
stm.close();
boolean cont = false;
L2PcInstance nPvpLord = L2World.getInstance().getPlayer(newPvpLord);
if (nPvpLord == null || nPvpLord.isOnline() == 0)
{
cont = true;
}
else
{
nPvpLord.setPvpLord(true);
nPvpLord.broadcastPacket(new SocialAction(nPvpLord.getObjectId(), 16));
nPvpLord.setIsHero(true);
nPvpLord.getAppearance().setNameColor(0xFF6633);
nPvpLord.broadcastUserInfo();
}
if (cont)
{
stm = con.prepareStatement("UPDATE characters SET pvplord=? WHERE char_name=?");
stm.setInt(1, 1);
stm.setString(2, newPvpLord);
stm.execute();
stm.close();
}
stm = con.prepareStatement("UPDATE characters SET todaypvps=?");
stm.setInt(1, 0);
stm.execute();
stm.close();
Announcements.getInstance().announceToAll("New pvp lord: " + newPvpLord + " Today pvps: " + topTodayPvps);
}
catch (Exception e)
{ }
finally
{
try
{
con.close();
}
catch (Exception e)
{ }
}
}
}
, getValidationTime());
}
private static long getValidationTime()
{
Calendar cld = Calendar.getInstance();
cld.set(Calendar.HOUR_OF_DAY, 14);
cld.set(Calendar.MINUTE, 40);
long time = cld.getTimeInMillis();
if (System.currentTimeMillis()-time <= 0)
{
return time - System.currentTimeMillis();
}
return 0;
}
}
and i thing something wrong with that place:
private static long getValidationTime()
{
Calendar cld = Calendar.getInstance();
cld.set(Calendar.HOUR_OF_DAY, 14);
cld.set(Calendar.MINUTE, 40);
long time = cld.getTimeInMillis();
if (System.currentTimeMillis()-time <= 0)
{
return time - System.currentTimeMillis();
}
return 0;
}
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
DISCORD :
https://discord.com/users/325653525793210378
utchiha_market
telegram :
https://t.me/utchiha_market
SELLIX STORE :
https://utchihamkt.mysellix.io/
Join our server for more products :
https://discord.gg/uthciha-services
https://campsite.bio/utchihaamkt
Question
DNG3R
i found http://maxcheaters.com/forum/index.php?topic=238056.0 and added to my pack and period change not working.
code:
and i thing something wrong with that place:
help me :)
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.