Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
Index: net.sf.l2j;Config.java =================================================================== --- net.sf.l2j;Config.java (revision 84) +++ net.sf.l2j;Config.java (working copy) + public static final int REWARD_PER_TIME_MODE_RESTRICTION = 2; Index: l2jban.renwalday;;DailyRewardManager.java =================================================================== --- l2jban.renwalday;;DailyRewardManager.java (revision 84) +++ l2jban.renwalday;;DailyRewardManager.java (working copy) + package l2jban.renwalday; + + import java.sql.Connection; + import java.sql.Date; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import java.text.SimpleDateFormat; + import java.util.Calendar; + + import net.sf.l2j.commons.concurrent.ThreadPool; + + import net.sf.l2j.Config; + import net.sf.l2j.L2DatabaseFactory; + + import net.sf.l2j.gameserver.model.actor.Player; + import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; + + /** + * @author Gabia + * + */ + public class DailyRewardManager + { + private static int rewardId = 3470; + + protected DailyRewardManager() + { + loadSystemThread(); + + System.out.println("Daily Reward Manager: Loaded"); + } + + protected static void loadSystemThread() + { + long spawnMillis = 0; + + Calendar c = Calendar.getInstance(); + + String[] time = "24:00".split(":"); + c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH)+1); + c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time[0])); + c.set(Calendar.MINUTE, Integer.parseInt(time[1])); + c.set(Calendar.SECOND, 0); + spawnMillis = c.getTimeInMillis() - System.currentTimeMillis(); + + ThreadPool.schedule(new Runnable() + { + @Override + public void run() + { + clearDBTable(); + + // Reload the system + loadSystemThread(); + + System.out.println("[Daily Reward] Table cleaned and restart the thread."); + } + }, spawnMillis); + } + + @SuppressWarnings("resource") + protected static void clearDBTable() + { + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + PreparedStatement statement = con.prepareStatement("DELETE FROM reward_manager"); + statement.execute(); + statement.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static void initialAllEngines(Player activeChar) + { + if(checkIfIPorHWIDExistInDB(activeChar, "ip") || checkIfIPorHWIDExistInDB(activeChar, "hwid")) + { + if(DailyRewardManager.checkForLatestHWIDReward(activeChar, "ip") || DailyRewardManager.checkForLatestHWIDReward(activeChar, "hwid")) // Rewarded + { + if(DailyRewardManager.checkForLatestHWIDReward(activeChar, "ip")) + activeChar.sendMessage("Join again in "+Cd(activeChar, "ip", false)+" to get your daily reward."); + else if(DailyRewardManager.checkForLatestHWIDReward(activeChar, "hwid")) + activeChar.sendMessage("Join again in "+Cd(activeChar, "hwid", false)+" to get your daily reward."); + } + else { // Not rewarded + + openDailyRewardHtml(activeChar); + } + } + else // If not exist in Database + { + openDailyRewardHtml(activeChar); + } + } + + public void claimDailyReward(Player player) + { + if(checkIfIPorHWIDExistInDB(player, "ip") || checkIfIPorHWIDExistInDB(player, "hwid")) + { + if(DailyRewardManager.checkForLatestHWIDReward(player, "ip") || DailyRewardManager.checkForLatestHWIDReward(player, "hwid")) // Rewarded + { + if(DailyRewardManager.checkForLatestHWIDReward(player, "ip")) + player.sendMessage("Join in "+Cd(player, "ip", false)+" to get your reward."); + else if(DailyRewardManager.checkForLatestHWIDReward(player, "hwid")) + player.sendMessage("Join in "+Cd(player, "hwid", false)+" to get your reward."); + } + else { // Not rewarded + //System.out.println("Not rewarded"); + if(checkIfIPorHWIDExistInDB(player, "ip")) + updateLastReward(player, "ip"); + + if(checkIfIPorHWIDExistInDB(player, "hwid")) + updateLastReward(player, "hwid"); + + giveReward(player); + } + } + else // Insert new Parent and reward + { + insertNewParentOfPlayerIPHWID(player); + giveReward(player); + } + + + } + + private static void openDailyRewardHtml(Player player) + { + NpcHtmlMessage htm = new NpcHtmlMessage(0); + htm.setFile("data/html/dailyrewards/index.htm"); + htm.replace("", ""); + player.sendPacket(htm); + } + + /** + * @param player + * + */ + private static void giveReward(Player player) + { + player.addItem("HWIDRewardManager", rewardId, 1, null, true); + + /*player.sendMessage("You are rewarded from daily reward."); + for(double infos[] : Config.REWARD_PER_TIME_ITEMLIST) + { + int chanceIndex = (int) (infos[2] * 1000); + + if (Rnd.get(100000) <= chanceIndex) + { + int itemId = (int) infos[0]; + int itemCount = (int) infos[1]; + + player.addItem("HWIDRewardManager", itemId, itemCount, null, true); + } + }*/ + } + + @SuppressWarnings("unused") + private static boolean checkForLatestHWIDReward(Player activeChar, String mode) + { + if(Config.REWARD_PER_TIME_MODE_RESTRICTION == 0 && mode.equals("hwid")) + return false; + + if(Config.REWARD_PER_TIME_MODE_RESTRICTION == 1 && mode.equals("ip")) + return false; + + //System.out.println("Config: "+Config.REWARD_PER_TIME_MODE_RESTRICTION+" Mode Check: "+mode); + return Long.parseLong(Cd(activeChar, mode, true)) > System.currentTimeMillis(); + } + + @SuppressWarnings("resource") + private static void updateLastReward(Player player, String mode) + { + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + PreparedStatement statement = con.prepareStatement("UPDATE reward_manager SET expire_time=? WHERE "+mode+"=?"); + statement.setLong(1, System.currentTimeMillis()); + statement.setString(2, (mode.equals("ip") ? player.getIP() : player.getHWID())); + statement.execute(); + statement.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @SuppressWarnings("resource") + private static String Cd(Player player, String mode, boolean returnInTimestamp) + { + long CdMs = 0; + long voteDelay = 1440 * 60000L; + + PreparedStatement statement = null; + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + statement = con.prepareStatement("SELECT expire_time FROM reward_manager WHERE "+mode+"=?"); + statement.setString(1, (mode.equals("ip") ? player.getIP() : player.getHWID())); + + ResultSet rset = statement.executeQuery(); + + while (rset.next()) + { + CdMs = rset.getLong("expire_time"); + } + + if((CdMs + voteDelay) < System.currentTimeMillis()) + CdMs = System.currentTimeMillis() - voteDelay; + + rset.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + try + { + if(statement != null) + statement.close(); + } + catch (SQLException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm"); + + if(returnInTimestamp) + return String.valueOf(CdMs+voteDelay); + + Date resultdate = new Date(CdMs + voteDelay); + return sdf.format(resultdate); + } + + @SuppressWarnings("resource") + private static boolean checkIfIPorHWIDExistInDB(Player player, String mode) + { + boolean flag = false; + PreparedStatement statement = null; + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + statement = con.prepareStatement("SELECT * FROM reward_manager WHERE "+mode+"=?"); + statement.setString(1, (mode.equals("ip") ? player.getIP() : player.getHWID())); + + ResultSet rset = statement.executeQuery(); + + if (rset.next()) + flag = true; + + rset.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + try + { + if(statement != null) + statement.close(); + } + catch (SQLException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return flag; + } + + @SuppressWarnings("resource") + private static void insertNewParentOfPlayerIPHWID(Player player) + { + PreparedStatement statement = null; + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + statement = con.prepareStatement("INSERT INTO reward_manager (ip,hwid,expire_time) VALUES (?,?,?)"); + statement.setString(1, player.getIP()); + statement.setString(2, player.getHWID()); + statement.setLong(3, System.currentTimeMillis()); + statement.execute(); + statement.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + try + { + if(statement != null) + statement.close(); + } + catch (SQLException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public static DailyRewardManager getInstance() + { + return SingletonHolder._instance; + } + + private static class SingletonHolder + { + protected static final DailyRewardManager _instance = new DailyRewardManager(); + } + + } + + Index: net.sf.l2j.gameserver.model.actor;Player.java =================================================================== --- net.sf.l2j.gameserver.model.actor;Player.java (revision 84) +++ net.sf.l2j.gameserver.model.actor;Player.java (working copy) private static final String UPDATE_CHARACTER +lasthwid=? WHERE obj_id=?"; public static Player restore(int objectId) { Player player = null; try (Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER)) - player.setPledgeType(rs.getInt("subpledge")); + player.setPledgeType(rs.getInt("subpledge")); + player.setLastHWID(rs.getString("lasthwid")); + private String lasthwid = ""; // Empty String + + public void setLastHWID(String val) + { + lasthwid = val; + } + + public String getLastHWID() + { + return lasthwid; + } + public String getHWID() + { + return getClient().getHWID() != null ? getClient().getHWID() : this.getName(); + } + + public String getIP() + { + if(getClient().getConnection() == null) + return "N/A IP"; + + return getClient().getConnection().getInetAddress().getHostAddress(); + } Index: net.sf.l2j.gameserver.network;GameClient.java =================================================================== --- net.sf.l2j.gameserver.network;GameClient.java (revision 84) +++ net.sf.l2j.gameserver.network;GameClient.java (working copy) + private String _hwid; + public void setHWID(String value) + { + _hwid = value; + } + + public String getHWID() + { + return _hwid; + } Index: net.sf.l2j.gameserver;GameServer.java =================================================================== --- net.sf.l2j.gameserver;GameServer.java (revision 84) +++ net.sf.l2j.gameserver;GameServer.java (working copy) + import l2jban.renwalday.DailyRewardManager; + + + DailyRewardManager.getInstance(); Index: net.sf.l2j.gameserver.network.clientpackets;EnterWorld.java =================================================================== --- net.sf.l2j.gameserver.network.clientpackets;EnterWorld.java (revision 84) +++ net.sf.l2j.gameserver.network.clientpackets;EnterWorld.java (working copy) + import l2jban.renwalday.DailyRewardManager.java + // Daily Reward System + DailyRewardManager.initialAllEngines(activeChar); Index: net.sf.l2j.gameserver.network.clientpackets;;RequestBypassToServer.java =================================================================== --- net.sf.l2j.gameserver.network.clientpackets;;RequestBypassToServer.java (revision 84) +++ net.sf.l2j.gameserver.network.clientpackets;;RequestBypassToServer.java (working copy) + import l2jban.renwalday.DailyRewardManager.java - else if (_command.startsWith("arenachange")) // change - { - final boolean isManager = activeChar.getCurrentFolkNPC() instanceof OlympiadManagerNpc; - if (!isManager) - { - // Without npc, command can be used only in observer mode on arena - if (!activeChar.isInObserverMode() || activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() < 0) - return; - } - - if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) - { - activeChar.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME); - return; - } - - final int arenaId = Integer.parseInt(_command.substring(12).trim()); - activeChar.enterOlympiadObserverMode(arenaId); - } + else if (_command.startsWith("arenachange")) // change + { + final boolean isManager = activeChar.getCurrentFolkNPC() instanceof OlympiadManagerNpc; + if (!isManager) + { + // Without npc, command can be used only in observer mode on arena + if (!activeChar.isInObserverMode() || activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() < 0) + return; + } + + if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) + { + activeChar.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME); + return; + } + + final int arenaId = Integer.parseInt(_command.substring(12).trim()); + activeChar.enterOlympiadObserverMode(arenaId); + } + else if (_command.startsWith("claimDailyReward")) + { + DailyRewardManager.getInstance().claimDailyReward(activeChar); + } Index: data/html/dailyrewards/index.htm =================================================================== --- data/html/dailyrewards/index.htm (revision 84) +++ data/html/dailyrewards/index.htm (working copy) + <html> + <title> + Daily Reward + </title> + <body> + <center> + <br> + <img src="l2ui.squaregray" width="295" height="1"> + + <font color=LEVEL>Claim your daily chest reward</font> + <br> + <font color="ff6600">Reset Every 24:00 AM</font> + <br> + + <img src="icon.etc_treasure_box_i02" width=32 height=32> + <br><br> + + <button value="Claim Daily Reward" action="bypass -h claimDailyReward" width=204 height=19 back="ban.btn_over" fore="ban.btn"> + + + <img src="l2ui.squaregray" width="295" height="1"> + <br> + <br> + <img src="l2ui.squaregray" width="295" height="1"> + <table width=295 bgcolor="000000"> + <tr> + <td align=center><img src=FondosDevs.domain width=300 height=20></td> + </tr> + </table> + </center> + </body> + </html>
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Trading method
CSS | 1 min ago | 0.28 KB
Google Docs - Exploit
14 min ago | 0.28 KB
SwapEngine Bug [build 1.3]
41 min ago | 0.28 KB
December smells like money
CSS | 54 min ago | 0.28 KB
Untitled
C | 10 hours ago | 0.88 KB
acg
1 day ago | 0.05 KB
AI METHODS
2 days ago | 0.29 KB
Untitled
2 days ago | 0.29 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!