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

81 lines
2.0 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;
import java.util.Map;
public class CreditsScheduler extends Scheduler
{
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public static boolean IGNORE_HOTEL_VIEW;
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public static boolean IGNORE_IDLED;
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public static int CREDITS;
2019-05-02 02:42:12 +02:00
public CreditsScheduler() {
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() {
2018-07-06 15:30:00 +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");
CREDITS = Emulator.getConfig().getInt("hotel.auto.credits.amount");
2019-05-02 02:42:12 +02:00
if (this.disposed) {
this.disposed = false;
this.run();
}
2018-07-06 15:30:00 +02:00
}
else
{
this.disposed = true;
}
}
@Override
public void run()
{
super.run();
Habbo habbo;
for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet())
{
habbo = map.getValue();
try
{
if (habbo != null)
{
if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
continue;
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue;
habbo.giveCredits(CREDITS);
}
}
catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
}
public boolean isDisposed()
{
2019-03-18 02:22:00 +01:00
return this.disposed;
2018-07-06 15:30:00 +02:00
}
public void setDisposed(boolean disposed)
{
this.disposed = disposed;
}
}