mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-25 20:04:01 +00:00
[AB-66] fixing not reducing the bid on mines
fixing reaction report sometimes running into a timeout
This commit is contained in:
@@ -23,8 +23,8 @@ import java.security.SecureRandom;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.sheldan.abstracto.entertainment.config.EconomyFeatureConfig.MINES_MINIMUM_MINES_RATIO;
|
||||
import static dev.sheldan.abstracto.entertainment.config.GamesFeatureConfig.MINES_CREDITS_FACTOR;
|
||||
import static dev.sheldan.abstracto.entertainment.config.GamesFeatureConfig.MINES_MINIMUM_MINES_RATIO;
|
||||
|
||||
@Component
|
||||
public class GameServiceBean implements GameService {
|
||||
@@ -134,6 +134,7 @@ public class GameServiceBean implements GameService {
|
||||
.build();
|
||||
Optional<EconomyUser> economyUserOptional = economyUserManagementService.getUser(serverUser);
|
||||
if(economyUserOptional.isPresent()) {
|
||||
economyService.addCredits(economyUserOptional.get(), -credits);
|
||||
economyService.addCredits(economyUserOptional.get(), creditChange);
|
||||
}
|
||||
mineBoard.setCreditChange(creditChange);
|
||||
|
||||
@@ -13,7 +13,6 @@ public class EconomyFeatureConfig implements FeatureConfig {
|
||||
public static final String PAYDAY_CREDITS_CONFIG_KEY = "paydayCredits";
|
||||
public static final String PAYDAY_COOLDOWN_CONFIG_KEY = "paydayCooldown";
|
||||
public static final String SLOTS_COOLDOWN_CONFIG_KEY = "slotsCooldown";
|
||||
public static final String MINES_MINIMUM_MINES_RATIO = "minesMinMineRatio";
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
@@ -22,6 +21,6 @@ public class EconomyFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return Arrays.asList(PAYDAY_CREDITS_CONFIG_KEY, PAYDAY_COOLDOWN_CONFIG_KEY, SLOTS_COOLDOWN_CONFIG_KEY, MINES_MINIMUM_MINES_RATIO);
|
||||
return Arrays.asList(PAYDAY_CREDITS_CONFIG_KEY, PAYDAY_COOLDOWN_CONFIG_KEY, SLOTS_COOLDOWN_CONFIG_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
public class GamesFeatureConfig implements FeatureConfig {
|
||||
|
||||
public static final String MINES_CREDITS_FACTOR = "minesCreditsFactor";
|
||||
public static final String MINES_MINIMUM_MINES_RATIO = "minesMinMineRatio";
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
@@ -19,7 +20,7 @@ public class GamesFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return Arrays.asList(MINES_CREDITS_FACTOR);
|
||||
return Arrays.asList(MINES_CREDITS_FACTOR, MINES_MINIMUM_MINES_RATIO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,33 +33,32 @@ public class ReportContextCommandListener implements MessageContextCommandListen
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(MessageContextInteractionModel model) {
|
||||
Message targetMessage = model.getEvent().getTarget();
|
||||
if(targetMessage.getAuthor().getIdLong() == model.getEvent().getUser().getIdLong()) {
|
||||
interactionService.replyEmbed(ReactionReportServiceBean.REACTION_REPORT_OWN_MESSAGE_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
ServerUser userReporting = ServerUser
|
||||
.builder()
|
||||
.serverId(model.getServerId())
|
||||
.userId(model.getEvent().getUser().getIdLong())
|
||||
.isBot(model.getEvent().getUser().isBot())
|
||||
.build();
|
||||
|
||||
if(!reactionReportService.allowedToReport(userReporting)) {
|
||||
log.info("User {} was reported on message {} in server {} within the cooldown. Ignoring.",
|
||||
targetMessage.getAuthor().getIdLong(), targetMessage.getIdLong(), targetMessage.getGuild().getIdLong());
|
||||
interactionService.replyEmbed(ReactionReportServiceBean.REACTION_REPORT_COOLDOWN_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
|
||||
reactionReportService.createReactionReport(targetMessage, userReporting, null).exceptionally(throwable -> {
|
||||
log.error("Failed to create reaction report in server {} on message {} in channel {} with interaction.",
|
||||
model.getServerId(), targetMessage.getIdLong(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
return null;
|
||||
model.getEvent().deferReply(true).queue(interactionHook -> {
|
||||
Message targetMessage = model.getEvent().getTarget();
|
||||
if(targetMessage.getAuthor().getIdLong() == model.getEvent().getUser().getIdLong()) {
|
||||
interactionService.sendMessageToInteraction(ReactionReportServiceBean.REACTION_REPORT_OWN_MESSAGE_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
return;
|
||||
}
|
||||
ServerUser userReporting = ServerUser
|
||||
.builder()
|
||||
.serverId(model.getServerId())
|
||||
.userId(model.getEvent().getUser().getIdLong())
|
||||
.isBot(model.getEvent().getUser().isBot())
|
||||
.build();
|
||||
if(!reactionReportService.allowedToReport(userReporting)) {
|
||||
log.info("User {} was reported on message {} in server {} within the cooldown. Ignoring.",
|
||||
targetMessage.getAuthor().getIdLong(), targetMessage.getIdLong(), targetMessage.getGuild().getIdLong());
|
||||
interactionService.sendMessageToInteraction(ReactionReportServiceBean.REACTION_REPORT_COOLDOWN_RESPONSE_TEMPLATE, new Object(),interactionHook);
|
||||
return;
|
||||
}
|
||||
reactionReportService.createReactionReport(targetMessage, userReporting, null).exceptionally(throwable -> {
|
||||
log.error("Failed to create reaction report in server {} on message {} in channel {} with interaction.",
|
||||
model.getServerId(), targetMessage.getIdLong(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
interactionService.sendMessageToInteraction(REACTION_REPORT_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
});
|
||||
|
||||
interactionService.replyEmbed(REACTION_REPORT_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
|
||||
return DefaultListenerResult.PROCESSED;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
|
||||
if(messageToSend.getEphemeral()) {
|
||||
Interaction interaction = interactionHook.getInteraction();
|
||||
interactionHook.setEphemeral(messageToSend.getEphemeral());
|
||||
log.info("Sending ephemeral message to interaction in guild {} in channel {} for user {}.",
|
||||
interaction.getGuild().getIdLong(), interaction.getChannel().getId(),
|
||||
interaction.getMember().getIdLong());
|
||||
|
||||
Reference in New Issue
Block a user