Arcturus-Community/src/main/java/com/eu/habbo/core/CreditsScheduler.java

71 lines
2.1 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
2020-05-03 01:46:07 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2018-07-06 15:30:00 +02:00
import java.util.Map;
2019-05-26 20:14:53 +02:00
public class CreditsScheduler extends Scheduler {
2018-07-08 23:32:00 +02:00
2020-05-03 01:46:07 +02:00
private static final Logger LOGGER = LoggerFactory.getLogger(CreditsScheduler.class);
2018-07-06 15:30:00 +02:00
public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED;
public static double HC_MODIFIER;
2018-07-06 15:30:00 +02:00
2019-05-02 02:42:12 +02:00
public CreditsScheduler() {
2019-07-17 02:33:19 +02:00
2018-07-06 15:30:00 +02:00
super(Emulator.getConfig().getInt("hotel.auto.credits.interval"));
2019-05-02 02:42:12 +02:00
this.reloadConfig();
}
2018-07-06 15:30:00 +02:00
2019-05-02 02:42:12 +02:00
public void reloadConfig() {
2019-05-26 20:14:53 +02:00
if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled");
HC_MODIFIER = Emulator.getConfig().getDouble("hotel.auto.credits.hc_modifier", 1.0);
2019-05-02 02:42:12 +02:00
if (this.disposed) {
this.disposed = false;
this.run();
}
2019-05-26 20:14:53 +02:00
} else {
2018-07-06 15:30:00 +02:00
this.disposed = true;
}
}
@Override
2019-05-26 20:14:53 +02:00
public void run() {
2018-07-06 15:30:00 +02:00
super.run();
Habbo habbo;
2019-05-26 20:14:53 +02:00
for (Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
2018-07-06 15:30:00 +02:00
habbo = map.getValue();
2019-05-26 20:14:53 +02:00
try {
if (habbo != null) {
2018-07-06 15:30:00 +02:00
if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
continue;
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue;
habbo.giveCredits((int)(habbo.getHabboInfo().getRank().getCreditsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0)));
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2020-05-03 01:46:07 +02:00
LOGGER.error("Caught exception", e);
2018-07-06 15:30:00 +02:00
}
}
}
2019-05-26 20:14:53 +02:00
public boolean isDisposed() {
2019-03-18 02:22:00 +01:00
return this.disposed;
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
public void setDisposed(boolean disposed) {
2018-07-06 15:30:00 +02:00
this.disposed = disposed;
}
}