mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-31 12:22:36 +01:00
Fix NullPointerExceptions
This commit is contained in:
parent
31711bd2f9
commit
8870145948
@ -16,6 +16,7 @@ import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 };
|
||||
@ -77,16 +78,17 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
parseCustomParams(item);
|
||||
}
|
||||
|
||||
public void parseCustomParams(Item baseItem) {
|
||||
private void parseCustomParams(Item baseItem) {
|
||||
try {
|
||||
String[] intervalSteps = baseItem.getCustomParams().split(",");
|
||||
int[] finalSteps = new int[intervalSteps.length];
|
||||
for (int i = 0; i < intervalSteps.length; i++) {
|
||||
finalSteps[i] = Integer.parseInt(intervalSteps[i]);
|
||||
TIMER_INTERVAL_STEPS = Arrays.stream(baseItem.getCustomParams().split(","))
|
||||
.mapToInt(s -> {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
TIMER_INTERVAL_STEPS = finalSteps;
|
||||
}
|
||||
catch (Exception e) {
|
||||
}).toArray();
|
||||
} catch (Exception e) {
|
||||
Emulator.getLogging().logErrorLine(e);
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class RoomUserWalkEvent extends MessageHandler {
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (!event.idle) {
|
||||
roomUnit.getRoom().unIdle(habbo);
|
||||
if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo);
|
||||
roomUnit.resetIdleTimer();
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,12 @@ public class UserEffectsListComposer extends MessageComposer {
|
||||
public ServerMessage compose() {
|
||||
this.response.init(Outgoing.UserEffectsListComposer);
|
||||
|
||||
if (this.habbo == null || this.habbo.getInventory() == null || this.habbo.getInventory().getEffectsComponent() == null || this.habbo.getInventory().getEffectsComponent().effects == null) {
|
||||
this.response.appendInt(0);
|
||||
} else {
|
||||
synchronized (this.habbo.getInventory().getEffectsComponent().effects) {
|
||||
this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size());
|
||||
this.habbo.getInventory().getEffectsComponent().effects.forEachValue(new TObjectProcedure<EffectsComponent.HabboEffect>() {
|
||||
@Override
|
||||
public boolean execute(EffectsComponent.HabboEffect effect) {
|
||||
this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> {
|
||||
UserEffectsListComposer.this.response.appendInt(effect.effect);
|
||||
UserEffectsListComposer.this.response.appendInt(0);
|
||||
UserEffectsListComposer.this.response.appendInt(effect.duration);
|
||||
@ -31,9 +32,10 @@ public class UserEffectsListComposer extends MessageComposer {
|
||||
UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1);
|
||||
UserEffectsListComposer.this.response.appendBoolean(effect.isActivated());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user