Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/de/rettichlp/ucutils/UCUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onInitialize() {
client.execute(() -> {
this.registry.registerListeners();
renderService.initializeWidgets();
syncService.sync(true);
syncService.checkForUpdates();
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/rettichlp/ucutils/command/ModCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public LiteralArgumentBuilder<FabricClientCommandSource> execute(@NotNull Litera
.then(literal("sync")
.then(literal("faction")
.executes(context -> {
syncService.syncFactionMembersWithCommandResponse();
syncService.syncFactionMembersWithCommand(() -> {});
return 1;
}))
.executes(context -> {
syncService.sync(true);
syncService.checkForUpdates();
syncService.syncFactionSpecificData();
return 1;
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static de.rettichlp.ucutils.UCUtils.commandService;
import static de.rettichlp.ucutils.UCUtils.messageService;
import static de.rettichlp.ucutils.UCUtils.utilService;
import static de.rettichlp.ucutils.common.services.CommandService.COMMAND_COOLDOWN_MILLIS;
import static java.lang.Integer.parseInt;
import static java.util.regex.Pattern.compile;

Expand All @@ -38,7 +39,7 @@ public LiteralArgumentBuilder<FabricClientCommandSource> execute(@NotNull Litera
} else {
commandService.sendCommand("bank einzahlen " + amount);
}
}, 1000);
}, COMMAND_COOLDOWN_MILLIS);

return 1;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static de.rettichlp.ucutils.UCUtils.messageService;
import static de.rettichlp.ucutils.UCUtils.storage;
import static de.rettichlp.ucutils.UCUtils.utilService;
import static de.rettichlp.ucutils.common.services.CommandService.COMMAND_COOLDOWN_MILLIS;

@UCUtilsCommand(label = "reichensteuer")
public class RichTaxesCommand extends CommandBase {
Expand All @@ -25,7 +26,7 @@ public LiteralArgumentBuilder<FabricClientCommandSource> execute(@NotNull Litera
commandService.sendCommand("bank info");

// execute command to check money in atm
utilService.delayedAction(() -> commandService.sendCommand("atminfo"), 1000);
utilService.delayedAction(() -> commandService.sendCommand("atminfo"), COMMAND_COOLDOWN_MILLIS);

// handle money withdraw
utilService.delayedAction(() -> {
Expand All @@ -52,7 +53,7 @@ public LiteralArgumentBuilder<FabricClientCommandSource> execute(@NotNull Litera
commandService.sendCommand("bank abbuchen " + moneyAtmAmount);
messageService.sendModMessage("Du musst noch " + (moneyThatNeedsToBeWithdrawn - moneyAtmAmount) + "$ abbuchen.", false);
}
}, 2000);
}, COMMAND_COOLDOWN_MILLIS * 2);

return 1;
});
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/de/rettichlp/ucutils/common/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import de.rettichlp.ucutils.common.models.BlackMarket;
import de.rettichlp.ucutils.common.models.BlacklistEntry;
import de.rettichlp.ucutils.common.models.BlacklistReason;
import de.rettichlp.ucutils.common.models.CommandResponseRetriever;
import de.rettichlp.ucutils.common.models.ContractEntry;
import de.rettichlp.ucutils.common.models.Countdown;
import de.rettichlp.ucutils.common.models.Faction;
Expand Down Expand Up @@ -48,9 +47,6 @@ public class Storage {
@Getter
private final List<BlackMarket> blackMarkets = new ArrayList<>();

@Getter
private final List<CommandResponseRetriever> commandResponseRetrievers = new ArrayList<>();

@Getter
private final List<ContractEntry> contractEntries = new ArrayList<>();

Expand Down Expand Up @@ -130,8 +126,6 @@ public void print() {
this.blacklistReasons.forEach((faction, blacklistReasons) -> LOGGER.info("blacklistReasons[{}:{}]: {}", faction, blacklistReasons.size(), blacklistReasons));
// blackMarkets
LOGGER.info("blackMarkets[{}]: {}", this.blackMarkets.size(), this.blackMarkets);
// commandResponseRetrievers
LOGGER.info("commandResponseRetrievers[{}]: {}", this.commandResponseRetrievers.size(), this.commandResponseRetrievers);
// contractEntries
LOGGER.info("contractEntries[{}]: {}", this.contractEntries.size(), this.contractEntries);
// countdowns
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/de/rettichlp/ucutils/common/api/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.function.Consumer;

import static de.rettichlp.ucutils.UCUtils.LOGGER;
import static de.rettichlp.ucutils.UCUtils.syncService;
import static de.rettichlp.ucutils.UCUtils.utilService;
import static java.lang.String.valueOf;
import static java.net.URI.create;
Expand Down Expand Up @@ -80,11 +79,6 @@ private <T> void get(@NotNull String uri, TypeToken<T> typeToken, Consumer<T> ca
}

private <T> void sendRequest(HttpRequest httpRequest, TypeToken<T> typeToken, Consumer<T> callback) {
if (!syncService.dataUsageConfirmed()) {
LOGGER.warn("Data usage not confirmed, skipping API request: [{}] {}", httpRequest.method(), httpRequest.uri().toString());
return;
}

this.httpClient.sendAsync(httpRequest, ofString())
.thenApply(this::catchDefaultApiError)
.thenApply(response -> ofNullable(typeToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class Configuration {
private int predictedPayDayExp = 0;
@Nullable
private LocalDateTime firstAidLicenseExpireDateTime = null;
private int dataUsageConfirmationUID = 0;
private Set<EventListener.HalloweenDoor> halloweenClickedDoors = new HashSet<>();

public void addMinutesSinceLastPayDay(int minutes) {
Expand Down

This file was deleted.

10 changes: 5 additions & 5 deletions src/main/java/de/rettichlp/ucutils/common/models/Faction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import static de.rettichlp.ucutils.UCUtils.storage;
import static java.util.Arrays.stream;
import static java.util.Collections.emptySet;
import static net.minecraft.text.Text.empty;
import static net.minecraft.util.Formatting.AQUA;
import static net.minecraft.util.Formatting.BLUE;
Expand Down Expand Up @@ -69,17 +69,17 @@ public Text getNameTagSuffix() {
.formatted(DARK_GRAY));
}

public Set<FactionMember> getMembers() {
public List<FactionMember> getMembers() {
return storage.getFactionEntries().stream()
.filter(factionEntry -> factionEntry.faction() == this)
.findFirst()
.map(FactionEntry::members)
.orElse(emptySet());
.orElse(new ArrayList<>());
}

public static @NotNull Optional<Faction> fromDisplayName(String displayName) {
return stream(values())
.filter(faction -> displayName.contains(faction.getDisplayName()))
.filter(faction -> faction.getDisplayName().equals(displayName))
.findFirst();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.rettichlp.ucutils.common.models;

import java.util.Set;
import java.util.List;

public record FactionEntry(Faction faction, Set<FactionMember> members) {
public record FactionEntry(Faction faction, List<FactionMember> members) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

public class CommandService {

public static long COMMAND_COOLDOWN_MILLIS = 500;

private static final String UUID_RETTICHLP = "25855f4d-3874-4a7f-a6ad-e9e4f3042e19";

public void sendCommand(String command) {
Expand All @@ -37,6 +39,10 @@ public boolean sendCommandWithAfkCheck(String command) {
}

public void sendCommands(List<String> commandStrings) {
sendCommands(commandStrings, COMMAND_COOLDOWN_MILLIS);
}

public void sendCommands(List<String> commandStrings, long cooldownMillis) {
// to modifiable list
List<String> commands = new ArrayList<>(commandStrings);

Expand All @@ -50,7 +56,7 @@ public void run() {

sendCommand(commands.removeFirst());
}
}, 0, 1000);
}, 0, cooldownMillis);
}

public boolean isSuperUser() {
Expand All @@ -61,6 +67,6 @@ public void retrieveNumberAndRun(String playerName, Consumer<Integer> runWithNum
sendCommand("nummer " + playerName);

utilService.delayedAction(() -> ofNullable(storage.getRetrievedNumbers().get(playerName))
.ifPresentOrElse(runWithNumber, () -> messageService.sendModMessage("Die Nummer von " + playerName + " konnte nicht abgerufen werden.", false)), 1000);
.ifPresentOrElse(runWithNumber, () -> messageService.sendModMessage("Die Nummer von " + playerName + " konnte nicht abgerufen werden.", false)), COMMAND_COOLDOWN_MILLIS);
}
}
Loading