Fix NPE in SecureLoginEvent

This commit is contained in:
Alejandro 2020-02-01 14:15:49 +02:00
parent 99168d57a5
commit 9561c0b073
3 changed files with 9 additions and 9 deletions

View File

@ -14,12 +14,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class EffectsComponent {
public final THashMap<Integer, HabboEffect> effects;
public final THashMap<Integer, HabboEffect> effects = new THashMap<>();
public final Habbo habbo;
public int activatedEffect = 0;
public EffectsComponent(Habbo habbo) {
this.effects = new THashMap<>();
this.habbo = habbo;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_effects WHERE user_id = ?")) {
statement.setInt(1, habbo.getHabboInfo().getId());

View File

@ -102,7 +102,7 @@ public class SecureLoginEvent extends MessageHandler {
messages.add(new SecureLoginOKComposer().compose());
messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose());
messages.add(new UserEffectsListComposer(habbo, client.getHabbo().getInventory().getEffectsComponent().effects.values().toArray(new EffectsComponent.HabboEffect[0])).compose());
messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose());
messages.add(new UserClothesComposer(this.client.getHabbo()).compose());
messages.add(new NewUserIdentityComposer(habbo).compose());
messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose());

View File

@ -6,13 +6,15 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.procedure.TObjectProcedure;
import java.util.Collection;
public class UserEffectsListComposer extends MessageComposer {
public final Habbo habbo;
public final EffectsComponent.HabboEffect[] effects;
public final Collection<EffectsComponent.HabboEffect> effects;
public UserEffectsListComposer(Habbo habbo, EffectsComponent.HabboEffect[] effects) {
public UserEffectsListComposer(Habbo habbo, Collection<EffectsComponent.HabboEffect> effects) {
this.habbo = habbo;
this.effects = effects;
}
@ -26,10 +28,9 @@ public class UserEffectsListComposer extends MessageComposer {
this.response.appendInt(0);
} else {
synchronized (this.habbo.getInventory().getEffectsComponent().effects) {
this.response.appendInt(this.effects.length);
this.response.appendInt(this.effects.size());
for (EffectsComponent.HabboEffect effect : effects) {
UserEffectsListComposer.this.response.appendInt(effect.effect);
UserEffectsListComposer.this.response.appendInt(0);
UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : Integer.MAX_VALUE);