mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
No more empty gifts!
This commit is contained in:
parent
529a84ec47
commit
f81470f7ba
@ -168,8 +168,13 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler {
|
|||||||
item.sellRare();
|
item.sellRare();
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalCredits = 0;
|
int totalCredits = item.getCredits();
|
||||||
int totalPoints = 0;
|
int totalPoints = item.getPoints();
|
||||||
|
|
||||||
|
if(totalCredits > this.client.getHabbo().getHabboInfo().getCredits() || totalPoints > this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType())) {
|
||||||
|
this.client.sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CatalogLimitedConfiguration limitedConfiguration;
|
CatalogLimitedConfiguration limitedConfiguration;
|
||||||
int limitedStack = 0;
|
int limitedStack = 0;
|
||||||
@ -224,103 +229,87 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
if (item.getAmount() > 1 || item.getBaseItems().size() > 1) {
|
||||||
if (item.getCredits() <= this.client.getHabbo().getHabboInfo().getCredits() - totalCredits) {
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||||
if (
|
return;
|
||||||
item.getPoints() <= this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints)
|
}
|
||||||
//item.getPointsType() == 0 && item.getPoints() <= this.client.getHabbo().getHabboInfo().getPixels() - totalPoints ||
|
|
||||||
|
|
||||||
{
|
for (Item baseItem : item.getBaseItems()) {
|
||||||
if (((i + 1) % 6 != 0 && CatalogItem.haveOffer(item)) || !CatalogItem.haveOffer(item)) {
|
if (item.getItemAmount(baseItem.getId()) > 1) {
|
||||||
totalCredits += item.getCredits();
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||||
totalPoints += item.getPoints();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < item.getAmount(); j++) {
|
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) {
|
||||||
if (item.getAmount() > 1 || item.getBaseItems().size() > 1) {
|
if (!baseItem.getName().contains("avatar_effect")) {
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
if (baseItem.getType() == FurnitureType.BADGE) {
|
||||||
return;
|
if (!badgeFound) {
|
||||||
}
|
if (habbo != null) {
|
||||||
for (Item baseItem : item.getBaseItems()) {
|
HabboBadge badge = new HabboBadge(0, baseItem.getName(), 0, habbo);
|
||||||
if (item.getItemAmount(baseItem.getId()) > 1) {
|
Emulator.getThreading().run(badge);
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
habbo.getInventory().getBadgesComponent().addBadge(badge);
|
||||||
return;
|
} else {
|
||||||
}
|
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, badge_code) VALUES (?, ?)")) {
|
||||||
|
statement.setInt(1, userId);
|
||||||
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) {
|
statement.setString(2, baseItem.getName());
|
||||||
if (!baseItem.getName().contains("avatar_effect")) {
|
statement.execute();
|
||||||
if (baseItem.getType() == FurnitureType.BADGE) {
|
|
||||||
if (!badgeFound) {
|
|
||||||
if (habbo != null) {
|
|
||||||
HabboBadge badge = new HabboBadge(0, baseItem.getName(), 0, habbo);
|
|
||||||
Emulator.getThreading().run(badge);
|
|
||||||
habbo.getInventory().getBadgesComponent().addBadge(badge);
|
|
||||||
} else {
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, badge_code) VALUES (?, ?)")) {
|
|
||||||
statement.setInt(1, userId);
|
|
||||||
statement.setString(2, baseItem.getName());
|
|
||||||
statement.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
badgeFound = true;
|
|
||||||
}
|
|
||||||
} else if (item.getName().startsWith("rentable_bot_")) {
|
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
|
||||||
return;
|
|
||||||
} else if (Item.isPet(baseItem)) {
|
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) {
|
|
||||||
if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && habbo != null && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) {
|
|
||||||
ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extraData));
|
|
||||||
extraData = "UMAD";
|
|
||||||
}
|
|
||||||
|
|
||||||
extraData = this.client.getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + extraData;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) {
|
|
||||||
HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
|
||||||
HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
|
||||||
Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId());
|
|
||||||
itemsList.add(teleportOne);
|
|
||||||
itemsList.add(teleportTwo);
|
|
||||||
} else if (baseItem.getInteractionType().getType() == InteractionHopper.class) {
|
|
||||||
HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData);
|
|
||||||
|
|
||||||
Emulator.getGameEnvironment().getItemManager().insertHopper(hopper);
|
|
||||||
|
|
||||||
itemsList.add(hopper);
|
|
||||||
} else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) {
|
|
||||||
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
|
||||||
habboItem.setExtradata("");
|
|
||||||
habboItem.needsUpdate(true);
|
|
||||||
int guildId;
|
|
||||||
try {
|
|
||||||
guildId = Integer.parseInt(extraData);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("Caught exception", e);
|
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Emulator.getThreading().run(habboItem);
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
|
|
||||||
itemsList.add(habboItem);
|
|
||||||
} else {
|
|
||||||
HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
|
||||||
itemsList.add(habboItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("error.catalog.buy.not_yet")));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badgeFound = true;
|
||||||
|
}
|
||||||
|
} else if (item.getName().startsWith("rentable_bot_")) {
|
||||||
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||||
|
return;
|
||||||
|
} else if (Item.isPet(baseItem)) {
|
||||||
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) {
|
||||||
|
if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && habbo != null && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) {
|
||||||
|
ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extraData));
|
||||||
|
extraData = "UMAD";
|
||||||
|
}
|
||||||
|
|
||||||
|
extraData = this.client.getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + extraData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) {
|
||||||
|
HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
||||||
|
HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
||||||
|
Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId());
|
||||||
|
itemsList.add(teleportOne);
|
||||||
|
itemsList.add(teleportTwo);
|
||||||
|
} else if (baseItem.getInteractionType().getType() == InteractionHopper.class) {
|
||||||
|
HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData);
|
||||||
|
|
||||||
|
Emulator.getGameEnvironment().getItemManager().insertHopper(hopper);
|
||||||
|
|
||||||
|
itemsList.add(hopper);
|
||||||
|
} else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) {
|
||||||
|
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
||||||
|
habboItem.setExtradata("");
|
||||||
|
habboItem.needsUpdate(true);
|
||||||
|
int guildId;
|
||||||
|
try {
|
||||||
|
guildId = Integer.parseInt(extraData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("Caught exception", e);
|
||||||
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Emulator.getThreading().run(habboItem);
|
||||||
|
Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
|
||||||
|
itemsList.add(habboItem);
|
||||||
|
} else {
|
||||||
|
HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
||||||
|
itemsList.add(habboItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("error.catalog.buy.not_yet")));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user