Set all credits/points event to the same method, added cancel for login event

This commit is contained in:
ArpyAge 2022-09-12 20:20:14 +02:00
parent 09b8b07d20
commit bb6a2e5eac
10 changed files with 29 additions and 51 deletions

View File

@ -548,13 +548,11 @@ public class CatalogManager {
voucher.addHistoryEntry(habbo.getHabboInfo().getId()); voucher.addHistoryEntry(habbo.getHabboInfo().getId());
if (voucher.points > 0) { if (voucher.points > 0) {
client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); client.getHabbo().givePoints(voucher.pointsType, voucher.points);
client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType));
} }
if (voucher.credits > 0) { if (voucher.credits > 0) {
client.getHabbo().getHabboInfo().addCredits(voucher.credits); client.getHabbo().giveCredits(voucher.credits);
client.sendResponse(new UserCreditsComposer(client.getHabbo()));
} }
if (voucher.catalogItemId > 0) { if (voucher.catalogItemId > 0) {
@ -1072,15 +1070,13 @@ public class CatalogManager {
if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) { if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
if (purchasedEvent.totalCredits > 0) { if (purchasedEvent.totalCredits > 0) {
habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.totalCredits); habbo.getClient().getHabbo().giveCredits(-purchasedEvent.totalCredits);
habbo.getClient().sendResponse(new UserCreditsComposer(habbo.getClient().getHabbo()));
} }
} }
if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) { if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) {
if (purchasedEvent.totalPoints > 0) { if (purchasedEvent.totalPoints > 0) {
habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -purchasedEvent.totalPoints); habbo.getClient().getHabbo().givePoints(item.getPointsType(), -purchasedEvent.totalPoints);
habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -purchasedEvent.totalPoints, item.getPointsType()));
} }
} }

View File

@ -279,12 +279,11 @@ public class MarketPlace {
client.getHabbo().getInventory().getItemsComponent().addItem(item); client.getHabbo().getInventory().getItemsComponent().addItem(item);
if (MARKETPLACE_CURRENCY == 0) { if (MARKETPLACE_CURRENCY == 0) {
client.getHabbo().getHabboInfo().addCredits(-event.price); client.getHabbo().giveCredits(-event.price);
} else { } else {
client.getHabbo().givePoints(MARKETPLACE_CURRENCY, -event.price); client.getHabbo().givePoints(MARKETPLACE_CURRENCY, -event.price);
} }
client.sendResponse(new UserCreditsComposer(client.getHabbo()));
client.sendResponse(new AddHabboItemComposer(item)); client.sendResponse(new AddHabboItemComposer(item));
client.sendResponse(new InventoryRefreshComposer()); client.sendResponse(new InventoryRefreshComposer());
client.sendResponse(new MarketplaceBuyErrorComposer(MarketplaceBuyErrorComposer.REFRESH, 0, offerId, price)); client.sendResponse(new MarketplaceBuyErrorComposer(MarketplaceBuyErrorComposer.REFRESH, 0, offerId, price));
@ -381,11 +380,10 @@ public class MarketPlace {
offers.clear(); offers.clear();
if (MARKETPLACE_CURRENCY == 0) { if (MARKETPLACE_CURRENCY == 0) {
client.getHabbo().getHabboInfo().addCredits(credits); client.getHabbo().giveCredits(credits);
} else { } else {
client.getHabbo().givePoints(MARKETPLACE_CURRENCY, credits); client.getHabbo().givePoints(MARKETPLACE_CURRENCY, credits);
} }
client.sendResponse(new UserCreditsComposer(client.getHabbo()));
} }
private static void removeUser(MarketPlaceOffer offer) { private static void removeUser(MarketPlaceOffer offer) {

View File

@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
import java.util.Map; import java.util.Map;
@ -30,7 +29,6 @@ public class MassCreditsCommand extends Command {
Habbo habbo = set.getValue(); Habbo habbo = set.getValue();
habbo.giveCredits(amount); habbo.giveCredits(amount);
habbo.getClient().sendResponse(new UserCreditsComposer(habbo));
if (habbo.getHabboInfo().getCurrentRoom() != null) if (habbo.getHabboInfo().getCurrentRoom() != null)
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", amount + ""), RoomChatMessageBubbles.ALERT); habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", amount + ""), RoomChatMessageBubbles.ALERT);

View File

@ -95,7 +95,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
return false; return false;
if (this.amount > 0) { if (this.amount > 0) {
habbo.getHabboInfo().addCurrencyAmount(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount); habbo.givePoints(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount);
habbo.getClient().sendResponse(new BonusRareComposer(habbo)); habbo.getClient().sendResponse(new BonusRareComposer(habbo));
} }

View File

@ -375,15 +375,13 @@ public class SubscriptionHabboClub extends Subscription {
case "coins": case "coins":
case "credit": case "credit":
case "coin": case "coin":
habbo.getClient().getHabbo().getHabboInfo().addCredits(amount); habbo.getClient().getHabbo().giveCredits(amount);
habbo.getClient().sendResponse(new UserCreditsComposer(habbo.getClient().getHabbo()));
break; break;
case "diamonds": case "diamonds":
case "diamond": case "diamond":
pointCurrency = 5; pointCurrency = 5;
habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); habbo.getClient().getHabbo().givePoints(pointCurrency, amount);
habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency));
break; break;
case "duckets": case "duckets":
@ -391,8 +389,7 @@ public class SubscriptionHabboClub extends Subscription {
case "pixels": case "pixels":
case "pixel": case "pixel":
pointCurrency = 0; pointCurrency = 0;
habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); habbo.getClient().getHabbo().givePoints(pointCurrency, amount);
habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency));
break; break;
default: default:
@ -405,8 +402,7 @@ public class SubscriptionHabboClub extends Subscription {
} }
if (pointCurrency >= 0) { if (pointCurrency >= 0) {
habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); habbo.getClient().getHabbo().givePoints(pointCurrency, amount);
habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency));
} }
break; break;
} }

View File

@ -58,10 +58,10 @@ public class CatalogBuyClubDiscountEvent extends MessageHandler {
return; return;
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS))
this.client.getHabbo().getHabboInfo().addCredits(-totalCredits); this.client.getHabbo().giveCredits(-totalCredits);
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS))
this.client.getHabbo().getHabboInfo().addCurrencyAmount(deal.getPointsType(), -totalDuckets); this.client.getHabbo().givePoints(deal.getPointsType(), -totalDuckets);
if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) { if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) {
@ -69,12 +69,6 @@ public class CatalogBuyClubDiscountEvent extends MessageHandler {
throw new Exception("Unable to create or extend subscription"); throw new Exception("Unable to create or extend subscription");
} }
if (totalCredits > 0)
this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo()));
if (totalDuckets > 0)
this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo()));
this.client.sendResponse(new PurchaseOKComposer(null)); this.client.sendResponse(new PurchaseOKComposer(null));
this.client.sendResponse(new InventoryRefreshComposer()); this.client.sendResponse(new InventoryRefreshComposer());

View File

@ -358,11 +358,10 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler {
} }
if (totalPoints > 0) { if (totalPoints > 0) {
if (item.getPointsType() == 0 && !this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_PIXELS)) { if (item.getPointsType() == 0 && !this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_PIXELS)) {
this.client.getHabbo().getHabboInfo().addPixels(-totalPoints); this.client.getHabbo().givePixels(-totalPoints);
} else if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) { } else if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) {
this.client.getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -totalPoints); this.client.getHabbo().givePoints(item.getPointsType(), -totalPoints);
} }
this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -totalPoints, item.getPointsType()));
} }
this.client.sendResponse(new PurchaseOKComposer(item)); this.client.sendResponse(new PurchaseOKComposer(item));

View File

@ -106,12 +106,10 @@ public class CatalogBuyItemEvent extends MessageHandler {
} }
((RoomBundleLayout) page).buyRoom(this.client.getHabbo()); ((RoomBundleLayout) page).buyRoom(this.client.getHabbo());
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) { //if the player has this perm disabled if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) { //if the player has this perm disabled
this.client.getHabbo().getHabboInfo().addCredits(-roomBundleItem.getCredits()); // takes their credits away this.client.getHabbo().giveCredits(-roomBundleItem.getCredits()); // takes their credits away
this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo())); // Sends the updated currency composer window
} }
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) { //if the player has this perm disabled if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) { //if the player has this perm disabled
this.client.getHabbo().getHabboInfo().addCurrencyAmount(roomBundleItem.getPointsType(), -roomBundleItem.getPoints()); // takes their points away this.client.getHabbo().givePoints(roomBundleItem.getPointsType(), -roomBundleItem.getPoints()); // takes their points away
this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo())); // Sends the updated currency composer window
} }
this.client.sendResponse(new PurchaseOKComposer()); // Sends the composer to close the window. this.client.sendResponse(new PurchaseOKComposer()); // Sends the composer to close the window.
@ -176,10 +174,10 @@ public class CatalogBuyItemEvent extends MessageHandler {
return; return;
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS))
this.client.getHabbo().getHabboInfo().addCredits(-totalCredits); this.client.getHabbo().giveCredits(-totalCredits);
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS))
this.client.getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -totalDuckets); this.client.getHabbo().givePoints(item.getPointsType(), -totalDuckets);
if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) { if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) {
@ -195,12 +193,6 @@ public class CatalogBuyItemEvent extends MessageHandler {
this.client.sendResponse(new UserPermissionsComposer(this.client.getHabbo())); this.client.sendResponse(new UserPermissionsComposer(this.client.getHabbo()));
this.client.sendResponse(new UserClubComposer(this.client.getHabbo()));*/ this.client.sendResponse(new UserClubComposer(this.client.getHabbo()));*/
if (totalCredits > 0)
this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo()));
if (totalDuckets > 0)
this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo()));
this.client.sendResponse(new PurchaseOKComposer(null)); this.client.sendResponse(new PurchaseOKComposer(null));
this.client.sendResponse(new InventoryRefreshComposer()); this.client.sendResponse(new InventoryRefreshComposer());

View File

@ -33,6 +33,7 @@ import com.eu.habbo.messages.outgoing.unknown.BuildersClubExpiredComposer;
import com.eu.habbo.messages.outgoing.mysterybox.MysteryBoxKeysComposer; import com.eu.habbo.messages.outgoing.mysterybox.MysteryBoxKeysComposer;
import com.eu.habbo.messages.outgoing.users.*; import com.eu.habbo.messages.outgoing.users.*;
import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent; import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent;
import com.eu.habbo.plugin.events.users.UserExecuteCommandEvent;
import com.eu.habbo.plugin.events.users.UserLoginEvent; import com.eu.habbo.plugin.events.users.UserLoginEvent;
import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.THashMap;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -186,7 +187,13 @@ public class SecureLoginEvent extends MessageHandler {
} }
} }
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getHabbo().getHabboInfo().getIpLogin())); UserLoginEvent userLoginEvent = new UserLoginEvent(habbo, this.client.getHabbo().getHabboInfo().getIpLogin());
Emulator.getPluginManager().fireEvent(userLoginEvent);
if(userLoginEvent.isCancelled()) {
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
return;
}
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) { if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
final Habbo finalHabbo = habbo; final Habbo finalHabbo = habbo;

View File

@ -107,8 +107,7 @@ public class RedeemItemEvent extends MessageHandler {
switch (furniRedeemEvent.currencyID) { switch (furniRedeemEvent.currencyID) {
case FurnitureRedeemedEvent.CREDITS: case FurnitureRedeemedEvent.CREDITS:
this.client.getHabbo().getHabboInfo().addCredits(furniRedeemEvent.amount); this.client.getHabbo().giveCredits(furniRedeemEvent.amount);
this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo()));
break; break;
case FurnitureRedeemedEvent.DIAMONDS: case FurnitureRedeemedEvent.DIAMONDS:
@ -116,8 +115,7 @@ public class RedeemItemEvent extends MessageHandler {
break; break;
case FurnitureRedeemedEvent.PIXELS: case FurnitureRedeemedEvent.PIXELS:
this.client.getHabbo().getHabboInfo().addPixels(furniRedeemEvent.amount); this.client.getHabbo().givePixels(furniRedeemEvent.amount);
this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo()));
break; break;
default: default: