2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.users ;
import com.eu.habbo.Emulator ;
import com.eu.habbo.habbohotel.catalog.CatalogItem ;
import com.eu.habbo.habbohotel.games.Game ;
import com.eu.habbo.habbohotel.games.GamePlayer ;
2022-03-19 20:34:21 +01:00
import com.eu.habbo.habbohotel.messenger.MessengerCategory ;
2019-05-27 15:00:22 +02:00
import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch ;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.permissions.Rank ;
2019-05-04 08:21:43 +02:00
import com.eu.habbo.habbohotel.pets.PetTasks ;
import com.eu.habbo.habbohotel.pets.RideablePet ;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.rooms.Room ;
2019-05-04 08:21:43 +02:00
import com.eu.habbo.habbohotel.rooms.RoomTile ;
import com.eu.habbo.habbohotel.rooms.RoomUnit ;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer ;
2018-07-06 15:30:00 +02:00
import gnu.trove.map.hash.TIntIntHashMap ;
import gnu.trove.procedure.TIntIntProcedure ;
2020-05-04 22:24:09 +02:00
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
2018-07-06 15:30:00 +02:00
2019-05-27 15:00:22 +02:00
import java.sql.* ;
2019-05-04 08:21:43 +02:00
import java.util.ArrayList ;
import java.util.List ;
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public class HabboInfo implements Runnable {
2020-05-04 22:24:09 +02:00
private static final Logger LOGGER = LoggerFactory . getLogger ( HabboInfo . class ) ;
2019-05-26 20:14:53 +02:00
public boolean firstVisit = false ;
2018-07-06 15:30:00 +02:00
private String username ;
private String motto ;
private String look ;
private HabboGender gender ;
private String mail ;
private String sso ;
private String ipRegister ;
private String ipLogin ;
private int id ;
private int accountCreated ;
private Rank rank ;
private int credits ;
private int lastOnline ;
private int homeRoom ;
private boolean online ;
private int loadingRoom ;
private Room currentRoom ;
private int roomQueueId ;
2019-05-04 08:21:43 +02:00
private RideablePet riding ;
2018-07-06 15:30:00 +02:00
private Class < ? extends Game > currentGame ;
private TIntIntHashMap currencies ;
private GamePlayer gamePlayer ;
private int photoRoomId ;
2020-01-23 20:24:53 +01:00
private int photoTimestamp ;
2018-07-06 15:30:00 +02:00
private String photoURL ;
private String photoJSON ;
private int webPublishTimestamp ;
private String machineID ;
2019-07-31 17:06:30 +02:00
private List < NavigatorSavedSearch > savedSearches = new ArrayList < > ( ) ;
2022-03-19 20:34:21 +01:00
private List < MessengerCategory > messengerCategories = new ArrayList < > ( ) ;
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public HabboInfo ( ResultSet set ) {
try {
2018-07-06 15:30:00 +02:00
this . id = set . getInt ( " id " ) ;
this . username = set . getString ( " username " ) ;
this . motto = set . getString ( " motto " ) ;
this . look = set . getString ( " look " ) ;
this . gender = HabboGender . valueOf ( set . getString ( " gender " ) ) ;
this . mail = set . getString ( " mail " ) ;
this . sso = set . getString ( " auth_ticket " ) ;
this . ipRegister = set . getString ( " ip_register " ) ;
this . ipLogin = set . getString ( " ip_current " ) ;
this . rank = Emulator . getGameEnvironment ( ) . getPermissionsManager ( ) . getRank ( set . getInt ( " rank " ) ) ;
2019-05-26 20:14:53 +02:00
if ( this . rank = = null ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " No existing rank found with id " + set . getInt ( " rank " ) + " . Make sure an entry in the permissions table exists. " ) ;
LOGGER . warn ( this . username + " has an invalid rank with id " + set . getInt ( " rank " ) + " . Make sure an entry in the permissions table exists. " ) ;
2019-05-15 22:36:11 +02:00
this . rank = Emulator . getGameEnvironment ( ) . getPermissionsManager ( ) . getRank ( 1 ) ;
2018-07-06 15:30:00 +02:00
}
this . accountCreated = set . getInt ( " account_created " ) ;
this . credits = set . getInt ( " credits " ) ;
this . homeRoom = set . getInt ( " home_room " ) ;
this . lastOnline = set . getInt ( " last_online " ) ;
this . machineID = set . getString ( " machine_id " ) ;
this . online = false ;
this . currentRoom = null ;
2019-05-26 20:14:53 +02:00
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2018-07-06 15:30:00 +02:00
}
this . loadCurrencies ( ) ;
2019-05-27 15:00:22 +02:00
this . loadSavedSearches ( ) ;
2022-03-19 20:34:21 +01:00
this . loadMessengerCategories ( ) ;
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
private void loadCurrencies ( ) {
2018-07-06 15:30:00 +02:00
this . currencies = new TIntIntHashMap ( ) ;
2019-05-26 20:14:53 +02:00
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " SELECT * FROM users_currency WHERE user_id = ? " ) ) {
2018-07-06 15:30:00 +02:00
statement . setInt ( 1 , this . id ) ;
2019-05-26 20:14:53 +02:00
try ( ResultSet set = statement . executeQuery ( ) ) {
while ( set . next ( ) ) {
2018-07-06 15:30:00 +02:00
this . currencies . put ( set . getInt ( " type " ) , set . getInt ( " amount " ) ) ;
}
}
2019-05-26 20:14:53 +02:00
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2018-07-06 15:30:00 +02:00
}
}
2019-05-26 20:14:53 +02:00
private void saveCurrencies ( ) {
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " INSERT INTO users_currency (user_id, type, amount) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE amount = ? " ) ) {
this . currencies . forEachEntry ( new TIntIntProcedure ( ) {
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public boolean execute ( int a , int b ) {
try {
2019-03-18 02:22:00 +01:00
statement . setInt ( 1 , HabboInfo . this . getId ( ) ) ;
2018-07-06 15:30:00 +02:00
statement . setInt ( 2 , a ) ;
statement . setInt ( 3 , b ) ;
statement . setInt ( 4 , b ) ;
statement . addBatch ( ) ;
2019-05-26 20:14:53 +02:00
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2018-07-06 15:30:00 +02:00
}
return true ;
}
} ) ;
statement . executeBatch ( ) ;
2019-05-26 20:14:53 +02:00
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2018-07-06 15:30:00 +02:00
}
}
2019-05-27 15:00:22 +02:00
private void loadSavedSearches ( ) {
2019-07-31 17:06:30 +02:00
this . savedSearches = new ArrayList < > ( ) ;
2019-05-27 15:00:22 +02:00
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " SELECT * FROM users_saved_searches WHERE user_id = ? " ) ) {
statement . setInt ( 1 , this . id ) ;
try ( ResultSet set = statement . executeQuery ( ) ) {
while ( set . next ( ) ) {
this . savedSearches . add ( new NavigatorSavedSearch ( set . getString ( " search_code " ) , set . getString ( " filter " ) , set . getInt ( " id " ) ) ) ;
}
}
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2019-05-27 15:00:22 +02:00
}
}
public void addSavedSearch ( NavigatorSavedSearch search ) {
this . savedSearches . add ( search ) ;
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " INSERT INTO users_saved_searches (search_code, filter, user_id) VALUES (?, ?, ?) " , Statement . RETURN_GENERATED_KEYS ) ) {
statement . setString ( 1 , search . getSearchCode ( ) ) ;
statement . setString ( 2 , search . getFilter ( ) ) ;
statement . setInt ( 3 , this . id ) ;
int affectedRows = statement . executeUpdate ( ) ;
if ( affectedRows = = 0 ) {
throw new SQLException ( " Creating saved search failed, no rows affected. " ) ;
}
try ( ResultSet generatedKeys = statement . getGeneratedKeys ( ) ) {
if ( generatedKeys . next ( ) ) {
search . setId ( generatedKeys . getInt ( 1 ) ) ;
} else {
throw new SQLException ( " Creating saved search failed, no ID found. " ) ;
}
}
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2019-05-27 15:00:22 +02:00
}
}
public void deleteSavedSearch ( NavigatorSavedSearch search ) {
this . savedSearches . remove ( search ) ;
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " DELETE FROM users_saved_searches WHERE id = ? " ) ) {
statement . setInt ( 1 , search . getId ( ) ) ;
statement . execute ( ) ;
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2019-05-27 15:00:22 +02:00
}
}
2022-03-19 20:34:21 +01:00
private void loadMessengerCategories ( ) {
this . messengerCategories = new ArrayList < > ( ) ;
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " SELECT * FROM messenger_categories WHERE user_id = ? " ) ) {
statement . setInt ( 1 , this . id ) ;
try ( ResultSet set = statement . executeQuery ( ) ) {
while ( set . next ( ) ) {
this . messengerCategories . add ( new MessengerCategory ( set . getString ( " name " ) , set . getInt ( " user_id " ) , set . getInt ( " id " ) ) ) ;
}
}
} catch ( SQLException e ) {
LOGGER . error ( " Caught SQL exception " , e ) ;
}
}
public void addMessengerCategory ( MessengerCategory category ) {
this . messengerCategories . add ( category ) ;
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " INSERT INTO messenger_categories (name, user_id) VALUES (?, ?) " , Statement . RETURN_GENERATED_KEYS ) ) {
statement . setString ( 1 , category . getName ( ) ) ;
statement . setInt ( 2 , this . id ) ;
int affectedRows = statement . executeUpdate ( ) ;
if ( affectedRows = = 0 ) {
throw new SQLException ( " Creating messenger category failed, no rows affected. " ) ;
}
try ( ResultSet generatedKeys = statement . getGeneratedKeys ( ) ) {
if ( generatedKeys . next ( ) ) {
category . setId ( generatedKeys . getInt ( 1 ) ) ;
} else {
throw new SQLException ( " Creating messenger category failed, no ID found. " ) ;
}
}
} catch ( SQLException e ) {
LOGGER . error ( " Caught SQL exception " , e ) ;
}
}
public void deleteMessengerCategory ( MessengerCategory category ) {
this . messengerCategories . remove ( category ) ;
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " DELETE FROM messenger_categories WHERE id = ? " ) ) {
statement . setInt ( 1 , category . getId ( ) ) ;
statement . execute ( ) ;
} catch ( SQLException e ) {
LOGGER . error ( " Caught SQL exception " , e ) ;
}
}
2019-05-26 20:14:53 +02:00
public int getCurrencyAmount ( int type ) {
2018-07-06 15:30:00 +02:00
return this . currencies . get ( type ) ;
}
2019-05-26 20:14:53 +02:00
public TIntIntHashMap getCurrencies ( ) {
2018-07-06 15:30:00 +02:00
return this . currencies ;
}
2019-05-26 20:14:53 +02:00
public void addCurrencyAmount ( int type , int amount ) {
2018-07-06 15:30:00 +02:00
this . currencies . adjustOrPutValue ( type , amount , amount ) ;
this . run ( ) ;
}
2019-05-26 20:14:53 +02:00
public void setCurrencyAmount ( int type , int amount ) {
2018-07-06 15:30:00 +02:00
this . currencies . put ( type , amount ) ;
this . run ( ) ;
}
2019-05-26 20:14:53 +02:00
public int getId ( ) {
2018-07-06 15:30:00 +02:00
return this . id ;
}
2019-05-26 20:14:53 +02:00
public String getUsername ( ) {
2018-07-06 15:30:00 +02:00
return this . username ;
}
2019-05-26 20:14:53 +02:00
public void setUsername ( String username ) {
2018-07-06 15:30:00 +02:00
this . username = username ;
}
2019-05-26 20:14:53 +02:00
public String getMotto ( ) {
2018-07-06 15:30:00 +02:00
return this . motto ;
}
2019-05-26 20:14:53 +02:00
public void setMotto ( String motto ) {
2018-07-06 15:30:00 +02:00
this . motto = motto ;
}
2019-05-26 20:14:53 +02:00
public Rank getRank ( ) {
2018-07-06 15:30:00 +02:00
return this . rank ;
}
2019-05-26 20:14:53 +02:00
public void setRank ( Rank rank ) {
2018-07-06 15:30:00 +02:00
this . rank = rank ;
}
2019-05-26 20:14:53 +02:00
public String getLook ( ) {
2018-07-06 15:30:00 +02:00
return this . look ;
}
2019-05-17 15:24:26 +02:00
public void setLook ( String look ) {
this . look = look ;
}
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public HabboGender getGender ( ) {
2018-07-06 15:30:00 +02:00
return this . gender ;
}
public void setGender ( HabboGender gender ) {
this . gender = gender ;
}
public String getMail ( ) {
2019-03-18 02:22:00 +01:00
return this . mail ;
2018-07-06 15:30:00 +02:00
}
public void setMail ( String mail ) {
this . mail = mail ;
}
public String getSso ( ) {
2019-03-18 02:22:00 +01:00
return this . sso ;
2018-07-06 15:30:00 +02:00
}
public void setSso ( String sso ) {
this . sso = sso ;
}
public String getIpRegister ( ) {
2019-03-18 02:22:00 +01:00
return this . ipRegister ;
2018-07-06 15:30:00 +02:00
}
public void setIpRegister ( String ipRegister ) {
this . ipRegister = ipRegister ;
}
2019-05-26 20:14:53 +02:00
public String getIpLogin ( ) {
2018-07-06 15:30:00 +02:00
return this . ipLogin ;
}
2019-05-26 20:14:53 +02:00
public void setIpLogin ( String ipLogin ) {
2018-07-06 15:30:00 +02:00
this . ipLogin = ipLogin ;
}
2019-05-26 20:14:53 +02:00
public int getAccountCreated ( ) {
2018-07-06 15:30:00 +02:00
return this . accountCreated ;
}
public void setAccountCreated ( int accountCreated ) {
this . accountCreated = accountCreated ;
}
2019-05-26 20:14:53 +02:00
public boolean canBuy ( CatalogItem item ) {
2018-07-06 15:30:00 +02:00
return this . credits > = item . getCredits ( ) & & this . getCurrencies ( ) . get ( item . getPointsType ( ) ) > = item . getPoints ( ) ;
}
2019-05-26 20:14:53 +02:00
public int getCredits ( ) {
2019-03-18 02:22:00 +01:00
return this . credits ;
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
public void setCredits ( int credits ) {
2018-07-06 15:30:00 +02:00
this . credits = credits ;
this . run ( ) ;
}
2019-05-26 20:14:53 +02:00
public void addCredits ( int credits ) {
2018-07-06 15:30:00 +02:00
this . credits + = credits ;
this . run ( ) ;
}
2019-05-26 20:14:53 +02:00
public int getPixels ( ) {
2018-07-06 15:30:00 +02:00
return this . getCurrencyAmount ( 0 ) ;
}
2019-05-26 20:14:53 +02:00
public void setPixels ( int pixels ) {
2018-07-06 15:30:00 +02:00
this . setCurrencyAmount ( 0 , pixels ) ;
this . run ( ) ;
}
2019-05-26 20:14:53 +02:00
public void addPixels ( int pixels ) {
2018-07-06 15:30:00 +02:00
this . addCurrencyAmount ( 0 , pixels ) ;
this . run ( ) ;
}
2019-05-26 20:14:53 +02:00
public int getLastOnline ( ) {
2018-07-06 15:30:00 +02:00
return this . lastOnline ;
}
2019-05-26 20:14:53 +02:00
public void setLastOnline ( int lastOnline ) {
2018-07-06 15:30:00 +02:00
this . lastOnline = lastOnline ;
}
2019-05-26 20:14:53 +02:00
public int getHomeRoom ( ) {
2018-07-06 15:30:00 +02:00
return this . homeRoom ;
}
2019-05-26 20:14:53 +02:00
public void setHomeRoom ( int homeRoom ) {
2018-07-06 15:30:00 +02:00
this . homeRoom = homeRoom ;
}
2019-05-26 20:14:53 +02:00
public boolean isOnline ( ) {
2018-07-06 15:30:00 +02:00
return this . online ;
}
2019-05-26 20:14:53 +02:00
public void setOnline ( boolean value ) {
2018-07-06 15:30:00 +02:00
this . online = value ;
}
2019-05-26 20:14:53 +02:00
public int getLoadingRoom ( ) {
2018-07-06 15:30:00 +02:00
return this . loadingRoom ;
}
2019-05-26 20:14:53 +02:00
public void setLoadingRoom ( int loadingRoom ) {
2018-07-06 15:30:00 +02:00
this . loadingRoom = loadingRoom ;
}
2019-05-26 20:14:53 +02:00
public Room getCurrentRoom ( ) {
2018-07-06 15:30:00 +02:00
return this . currentRoom ;
}
2019-05-26 20:14:53 +02:00
public void setCurrentRoom ( Room room ) {
2018-07-06 15:30:00 +02:00
this . currentRoom = room ;
}
2019-05-26 20:14:53 +02:00
public int getRoomQueueId ( ) {
2018-07-06 15:30:00 +02:00
return this . roomQueueId ;
}
2019-05-26 20:14:53 +02:00
public void setRoomQueueId ( int roomQueueId ) {
2018-07-06 15:30:00 +02:00
this . roomQueueId = roomQueueId ;
}
2019-05-26 20:14:53 +02:00
public RideablePet getRiding ( ) {
2019-03-18 02:22:00 +01:00
return this . riding ;
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
public void setRiding ( RideablePet riding ) {
this . riding = riding ;
}
2019-05-04 08:21:43 +02:00
public void dismountPet ( ) {
this . dismountPet ( false ) ;
}
public void dismountPet ( boolean isRemoving ) {
2019-05-26 20:14:53 +02:00
if ( this . getRiding ( ) = = null )
2019-05-04 08:21:43 +02:00
return ;
Habbo habbo = this . getCurrentRoom ( ) . getHabbo ( this . getId ( ) ) ;
2019-05-26 20:14:53 +02:00
if ( habbo = = null )
2019-05-04 08:21:43 +02:00
return ;
RideablePet riding = this . getRiding ( ) ;
riding . setRider ( null ) ;
riding . setTask ( PetTasks . FREE ) ;
this . setRiding ( null ) ;
Room room = this . getCurrentRoom ( ) ;
2019-05-26 20:14:53 +02:00
if ( room ! = null )
2019-05-04 08:21:43 +02:00
room . giveEffect ( habbo , 0 , - 1 ) ;
RoomUnit roomUnit = habbo . getRoomUnit ( ) ;
2019-05-26 20:14:53 +02:00
if ( roomUnit = = null )
2019-05-04 08:21:43 +02:00
return ;
roomUnit . setZ ( riding . getRoomUnit ( ) . getZ ( ) ) ;
roomUnit . setPreviousLocationZ ( riding . getRoomUnit ( ) . getZ ( ) ) ;
roomUnit . stopWalking ( ) ;
room . sendComposer ( new RoomUserStatusComposer ( roomUnit ) . compose ( ) ) ;
List < RoomTile > availableTiles = isRemoving ? new ArrayList < > ( ) : this . getCurrentRoom ( ) . getLayout ( ) . getWalkableTilesAround ( roomUnit . getCurrentLocation ( ) ) ;
RoomTile tile = availableTiles . isEmpty ( ) ? roomUnit . getCurrentLocation ( ) : availableTiles . get ( 0 ) ;
roomUnit . setGoalLocation ( tile ) ;
roomUnit . statusUpdate ( true ) ;
}
2019-05-26 20:14:53 +02:00
public Class < ? extends Game > getCurrentGame ( ) {
2018-07-06 15:30:00 +02:00
return this . currentGame ;
}
2019-05-26 20:14:53 +02:00
public void setCurrentGame ( Class < ? extends Game > currentGame ) {
2018-07-06 15:30:00 +02:00
this . currentGame = currentGame ;
}
2019-05-26 20:14:53 +02:00
public boolean isInGame ( ) {
2018-07-06 15:30:00 +02:00
return this . currentGame ! = null ;
}
2019-05-26 20:14:53 +02:00
public synchronized GamePlayer getGamePlayer ( ) {
2018-07-06 15:30:00 +02:00
return this . gamePlayer ;
}
2019-05-26 20:14:53 +02:00
public synchronized void setGamePlayer ( GamePlayer gamePlayer ) {
2018-07-06 15:30:00 +02:00
this . gamePlayer = gamePlayer ;
}
2019-05-26 20:14:53 +02:00
public int getPhotoRoomId ( ) {
2018-07-06 15:30:00 +02:00
return this . photoRoomId ;
}
2019-05-26 20:14:53 +02:00
public void setPhotoRoomId ( int roomId ) {
2018-07-06 15:30:00 +02:00
this . photoRoomId = roomId ;
}
2020-01-23 20:24:53 +01:00
public int getPhotoTimestamp ( ) {
2018-07-06 15:30:00 +02:00
return this . photoTimestamp ;
}
2020-01-23 20:24:53 +01:00
public void setPhotoTimestamp ( int photoTimestamp ) {
2018-07-06 15:30:00 +02:00
this . photoTimestamp = photoTimestamp ;
}
2019-05-26 20:14:53 +02:00
public String getPhotoURL ( ) {
2018-07-06 15:30:00 +02:00
return this . photoURL ;
}
2019-05-26 20:14:53 +02:00
public void setPhotoURL ( String photoURL ) {
2018-07-06 15:30:00 +02:00
this . photoURL = photoURL ;
}
2019-05-26 20:14:53 +02:00
public String getPhotoJSON ( ) {
2018-07-06 15:30:00 +02:00
return this . photoJSON ;
}
2019-05-26 20:14:53 +02:00
public void setPhotoJSON ( String photoJSON ) {
2018-07-06 15:30:00 +02:00
this . photoJSON = photoJSON ;
}
2019-05-26 20:14:53 +02:00
public int getWebPublishTimestamp ( ) {
2018-07-06 15:30:00 +02:00
return this . webPublishTimestamp ;
}
2019-05-26 20:14:53 +02:00
public void setWebPublishTimestamp ( int webPublishTimestamp ) {
2018-07-06 15:30:00 +02:00
this . webPublishTimestamp = webPublishTimestamp ;
}
2019-05-26 20:14:53 +02:00
public String getMachineID ( ) {
2018-07-06 15:30:00 +02:00
return this . machineID ;
}
2019-05-26 20:14:53 +02:00
public void setMachineID ( String machineID ) {
2018-07-06 15:30:00 +02:00
this . machineID = machineID ;
}
2019-07-31 17:06:30 +02:00
public List < NavigatorSavedSearch > getSavedSearches ( ) {
2019-05-27 15:00:22 +02:00
return this . savedSearches ;
}
2022-03-19 20:34:21 +01:00
public List < MessengerCategory > getMessengerCategories ( ) { return this . messengerCategories ; }
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public void run ( ) {
2018-07-06 15:30:00 +02:00
this . saveCurrencies ( ) ;
2019-05-26 20:14:53 +02:00
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, `rank` = ?, machine_id = ?, username = ? WHERE id = ? " ) ) {
2018-07-06 15:30:00 +02:00
statement . setString ( 1 , this . motto ) ;
statement . setString ( 2 , this . online ? " 1 " : " 0 " ) ;
statement . setString ( 3 , this . look ) ;
statement . setString ( 4 , this . gender . name ( ) ) ;
statement . setInt ( 5 , this . credits ) ;
statement . setInt ( 7 , this . lastOnline ) ;
statement . setInt ( 6 , Emulator . getIntUnixTimestamp ( ) ) ;
statement . setInt ( 8 , this . homeRoom ) ;
statement . setString ( 9 , this . ipLogin ) ;
2019-05-15 22:36:11 +02:00
statement . setInt ( 10 , this . rank ! = null ? this . rank . getId ( ) : 1 ) ;
2018-07-06 15:30:00 +02:00
statement . setString ( 11 , this . machineID ) ;
statement . setString ( 12 , this . username ) ;
statement . setInt ( 13 , this . id ) ;
statement . executeUpdate ( ) ;
2019-05-26 20:14:53 +02:00
} catch ( SQLException e ) {
2020-05-04 22:24:09 +02:00
LOGGER . error ( " Caught SQL exception " , e ) ;
2018-07-06 15:30:00 +02:00
}
}
2019-05-26 20:14:53 +02:00
public int getBonusRarePoints ( ) {
2018-07-06 15:30:00 +02:00
return this . getCurrencyAmount ( Emulator . getConfig ( ) . getInt ( " hotelview.promotional.points.type " ) ) ;
}
2019-05-11 00:45:07 +02:00
public HabboStats getHabboStats ( ) {
Habbo habbo = Emulator . getGameEnvironment ( ) . getHabboManager ( ) . getHabbo ( this . getId ( ) ) ;
2019-05-26 20:14:53 +02:00
if ( habbo ! = null ) {
2019-05-11 00:45:07 +02:00
return habbo . getHabboStats ( ) ;
}
return HabboStats . load ( this ) ;
}
2018-07-06 15:30:00 +02:00
}