Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/Quackster/Kepler
Browse files Browse the repository at this point in the history
  • Loading branch information
Quackster committed Oct 16, 2019
2 parents 5b946e1 + 5caa4a9 commit c6868ba
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
4 changes: 4 additions & 0 deletions Kepler-Server/src/main/java/org/alexdev/kepler/Kepler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.netty.util.ResourceLeakDetector;
import org.alexdev.kepler.dao.Storage;
import org.alexdev.kepler.dao.mysql.SettingsDao;
import org.alexdev.kepler.game.GameScheduler;
import org.alexdev.kepler.game.bot.BotManager;
import org.alexdev.kepler.game.catalogue.CatalogueManager;
Expand Down Expand Up @@ -104,6 +105,9 @@ public static void main(String[] args) {
TextsManager.getInstance();
RecyclerManager.getInstance();

// Update players online back to 0
SettingsDao.updateSetting("players.online", "0");

setupRcon();
setupMus();
setupServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,34 @@ public static Pair<Integer, Integer> getChoiceData(int choice) {
private static long getClubGiftSeconds() {
return TimeUnit.valueOf(GameConfiguration.getInstance().getString("club.gift.timeunit")).toSeconds(GameConfiguration.getInstance().getInteger("club.gift.interval"));
}

/**
* Refresh club page for user.
*
* @param player the player to check against
*/
public static void refreshBadge(Player player) {
if (!player.getDetails().hasClubSubscription()) {
// If the database still thinks we have Habbo club even after it expired, reset it back to 0.
if (player.getDetails().getClubExpiration() > 0) {
//player.getDetails().setFirstClubSubscription(0);
player.getDetails().setClubExpiration(0);
player.getDetails().getBadges().remove("HC1"); // If their HC ran out, remove badge.
player.getDetails().getBadges().remove("HC2"); // No gold badge when not subscribed.

player.refreshFuserights();
PlayerDao.saveSubscription(player.getDetails());
}
} else {
if (!player.getDetails().getBadges().contains("HC1")) {
player.getDetails().getBadges().add("HC1");
}

if (player.getDetails().hasGoldClubSubscription()) {
if (!player.getDetails().getBadges().contains("HC2")) {
player.getDetails().getBadges().add("HC2");
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
import io.netty.util.AttributeKey;
import org.alexdev.kepler.Kepler;
import org.alexdev.kepler.dao.mysql.PlayerDao;
import org.alexdev.kepler.dao.mysql.SettingsDao;
import org.alexdev.kepler.game.GameScheduler;
import org.alexdev.kepler.game.club.ClubSubscription;
import org.alexdev.kepler.game.entity.Entity;
import org.alexdev.kepler.game.entity.EntityType;
import org.alexdev.kepler.game.inventory.Inventory;
import org.alexdev.kepler.game.messenger.Messenger;
import org.alexdev.kepler.game.fuserights.Fuseright;
import org.alexdev.kepler.game.fuserights.FuserightsManager;
import org.alexdev.kepler.game.inventory.Inventory;
import org.alexdev.kepler.game.messenger.Messenger;
import org.alexdev.kepler.game.room.entities.RoomPlayer;
import org.alexdev.kepler.messages.outgoing.club.CLUB_GIFT;
import org.alexdev.kepler.messages.outgoing.handshake.*;
import org.alexdev.kepler.messages.outgoing.handshake.AVAILABLE_SETS;
import org.alexdev.kepler.messages.outgoing.handshake.LOGIN;
import org.alexdev.kepler.messages.outgoing.handshake.RIGHTS;
import org.alexdev.kepler.messages.outgoing.moderation.USER_BANNED;
import org.alexdev.kepler.messages.outgoing.openinghours.*;
import org.alexdev.kepler.messages.outgoing.openinghours.INFO_HOTEL_CLOSING;
import org.alexdev.kepler.messages.outgoing.user.ALERT;
import org.alexdev.kepler.messages.outgoing.user.HOTEL_LOGOUT;
import org.alexdev.kepler.messages.outgoing.user.HOTEL_LOGOUT.*;
import org.alexdev.kepler.messages.outgoing.user.HOTEL_LOGOUT.LogoutReason;
import org.alexdev.kepler.messages.types.MessageComposer;
import org.alexdev.kepler.server.netty.NettyPlayerNetwork;
import org.alexdev.kepler.util.config.GameConfiguration;
Expand Down Expand Up @@ -73,6 +76,8 @@ public void login() {
PlayerDao.clearSSOTicket(this.details.getId()); // Protect against replay attacks
}

SettingsDao.updateSetting("players.online", String.valueOf(PlayerManager.getInstance().getPlayers().size()));

this.messenger = new Messenger(this.details);
this.inventory = new Inventory(this);

Expand Down Expand Up @@ -114,39 +119,18 @@ public void login() {
}

this.messenger.sendStatusUpdate();
ClubSubscription.refreshBadge(this);
}

/**
* Refresh club for player.
*/
public void refreshClub() {
if (!this.details.hasClubSubscription()) {
// If the database still thinks we have Habbo club even after it expired, reset it back to 0.
if (this.details.getClubExpiration() > 0) {
//this.details.setFirstClubSubscription(0);
this.details.setClubExpiration(0);
this.details.getBadges().remove("HC1"); // If their HC ran out, remove badge.
this.details.getBadges().remove("HC2"); // No gold badge when not subscribed.

this.refreshFuserights();
PlayerDao.saveSubscription(this.details);
}
} else {
if (!this.details.getBadges().contains("HC1")) {
this.details.getBadges().add("HC1");
}

if (this.details.hasGoldClubSubscription()) {
if (!this.details.getBadges().contains("HC2")) {
this.details.getBadges().add("HC2");
}
}
}

if (this.details.hasClubSubscription()) {
this.send(new AVAILABLE_SETS("[" + GameConfiguration.getInstance().getString("users.figure.parts.club") + "]"));
}

ClubSubscription.refreshBadge(this);
ClubSubscription.sendHcDays(this);
}

Expand Down Expand Up @@ -318,8 +302,9 @@ public void dispose() {
}

PlayerDao.saveLastOnline(this.getDetails());
PlayerManager.getInstance().removePlayer(this);
SettingsDao.updateSetting("players.online", String.valueOf(PlayerManager.getInstance().getPlayers().size()));

PlayerManager.getInstance().removePlayer(this);
this.messenger.sendStatusUpdate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ private void setConfigurationDefaults() {
//config.put("recycler.session.length.seconds", "3600");
config.put("recycler.item.quarantine.seconds", "2592000");

config.put("players.online", "0");

// Catalogue pages for rare items, delimetered by pipe, first integer is page ID and second number is the amount of hours required for that rare to be affordable
config.put("rare.cycle.pages", "28,3|29,3|31,3|32,3|33,3|34,3|35,3|36,3|40,3|43,3|30,6|37,6|38,6|39,6|44,6");
}
Expand Down

0 comments on commit c6868ba

Please sign in to comment.