Skip to content

Commit

Permalink
Add a lockdown warning
Browse files Browse the repository at this point in the history
This message gets printed on the first craft after which lockdown was enabled, then every hour once on a single crafting attempt.
  • Loading branch information
WolfyScript committed Jan 10, 2024
1 parent 54d5ad4 commit 5abf142
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -56,6 +56,7 @@

public final class CraftManager {

private long lastLockDownWarning = 0;
private final Map<UUID, CraftingData> preCraftedRecipes = new HashMap<>();
private final Map<InventoryView, MatrixData> currentMatrixData = new HashMap<>();
private final CustomCrafting customCrafting;
Expand Down Expand Up @@ -84,7 +85,13 @@ public void clearCurrentMatrixData(InventoryView view) {
*/
public Optional<CraftingData> checkCraftingMatrix(ItemStack[] matrix, Conditions.Data data, RecipeType.Container.CraftingContainer<?>... types) {
data.player().ifPresent(player -> remove(player.getUniqueId()));
if (customCrafting.getConfigHandler().getConfig().isLockedDown()) return Optional.empty();
if (customCrafting.getConfigHandler().getConfig().isLockedDown()) {
if (System.currentTimeMillis() > lastLockDownWarning + (1000 * 60 * 60)) {
customCrafting.getLogger().warning("Lockdown is enabled! All custom recipes are blocked!");
lastLockDownWarning = System.currentTimeMillis();
}
return Optional.empty();
}
var matrixData = MatrixData.of(matrix);
return customCrafting.getRegistries().getRecipes().get(types)
.sorted() // Possibility for parallel stream when enough recipes are registered to amortize the overhead. (Things like the PreCraftEvent might interfere. TODO: Experimental Feature)
Expand Down

0 comments on commit 5abf142

Please sign in to comment.