Skip to content

Conversation

@RitaSister
Copy link

First support for folia in this plugin. There may still be areas that require revision.

Copy link
Member

@Jsinco Jsinco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else looks fine at a glance, just proposing changes to ticking those cauldrons

.orElse(Color.GRAY);

this.playBrewingEffects();
Optional<World> optionalWorld = BukkitAdapter.toWorld(location);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like Nadwey said, this shouldn't be creating a fixed-rate scheduler. I also don't think the folia scheduler object is needed here either

Suggested change
Optional<World> optionalWorld = BukkitAdapter.toWorld(location);
Location bukkitLocation = BukkitAdapter.toLocation(location);
SinglePositionStructure structure = this;
Bukkit.getRegionScheduler().run(TheBrewingProject.getInstance(), bukkitLocation, (task) -> {
if (!BlockUtil.isChunkLoaded(location)) {
return;
}
if (!Tag.CAULDRONS.isTagged(getBlock().getType()) || getBlock().getType() == Material.CAULDRON) {
ListenerUtil.removeActiveSinglePositionStructure(structure, TheBrewingProject.getInstance().getBreweryRegistry(), TheBrewingProject.getInstance().getDatabase());
return;
}
hot = isHeatSource(getBlock().getRelative(BlockFace.DOWN));
recalculateBrewTime();
Color baseParticleColor = computeBaseParticleColor(getBlock());
Optional<Recipe<ItemStack>> recipeOptional = brew.closestRecipe(TheBrewingProject.getInstance().getRecipeRegistry());
Color resultColor = computeResultColor(recipeOptional);
particleColor = recipeOptional.map(recipe -> computeParticleColor(baseParticleColor, resultColor, recipe))
.orElse(Color.GRAY);
playBrewingEffects();
});

@@ -0,0 +1,156 @@
package dev.jsinco.brewery.bukkit.util;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally left this comment out of my review:

I don't think this object needs to be here

Copy link
Contributor

@Thorinwasher Thorinwasher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to have everything that is done on inventories in the proper thread, this is important because otherwise there's nothing saying what or how something could get duped. See

List.copyOf(breweryRegistry.<BukkitBarrel>getOpened(StructureType.BARREL)).forEach(Barrel::tickInventory);
List.copyOf(breweryRegistry.<BukkitDistillery>getOpened(StructureType.DISTILLERY)).forEach(Distillery::tickInventory);

Comment on lines 202 to 203
Bukkit.getGlobalRegionScheduler().runAtFixedRate(this, task -> this.updateStructures(), 1, 1);
Bukkit.getGlobalRegionScheduler().runAtFixedRate(this, task -> this.otherTicking(), 1, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two methods would also by themself need to delegate to probably something like the local region scheduler for each structure.

.orElse(Color.GRAY);
playBrewingEffects();
}
}.runAtFixedRate(TheBrewingProject.getInstance(), 20, 1);
Copy link
Contributor

@Thorinwasher Thorinwasher Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to cause a memory leak. You could at least simplify it to runNow, no need for it to be more complicated than that

Comment on lines +202 to +203
Bukkit.getGlobalRegionScheduler().runAtFixedRate(this, task -> this.updateStructures(), 20, 1);
Bukkit.getGlobalRegionScheduler().runAtFixedRate(this, task -> this.otherTicking(), 20, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you delaying everything by 1 second?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is everything is 1 tick, idk how u do your system tick and how u are watch then processing that

Copy link
Contributor

@Thorinwasher Thorinwasher Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.otherTicking(), 20, 1);
                      ^ This is one second delay before everything starts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.otherTicking(), 20, 1);
                      ^ This is one second delay before everything starts

oh, if you mean that - I'm sorry

TheBrewingProject.getInstance().getActiveEventsRegistry().registerActiveEvent(playerUuid, event, Config.PUKE_TIME);
Bukkit.getScheduler().runTaskTimer(TheBrewingProject.getInstance(), pukeHandler::tick, 0, 1);

player.getScheduler().runAtFixedRate(TheBrewingProject.getInstance(), pukeHandler::tick,null ,1, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the delay from 0 ticks to 1 ticks?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the delay from 0 ticks to 1 ticks?

when folia scheduler don't allow set 0 on delay ticks. this is must be > 0 like 1 or more

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I did not know that. Good to know

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like something:

[11:57:23] [Server thread/ERROR]: Error occurred while enabling TheBrewingProject v1.7.0 (Is it up to date?) --   | java.lang.IllegalArgumentException: Initial delay ticks may not be <= 0

@RitaSister
Copy link
Author

You need to have everything that is done on inventories in the proper thread, this is important because otherwise there's nothing saying what or how something could get duped. See

List.copyOf(breweryRegistry.<BukkitBarrel>getOpened(StructureType.BARREL)).forEach(Barrel::tickInventory);
List.copyOf(breweryRegistry.<BukkitDistillery>getOpened(StructureType.DISTILLERY)).forEach(Distillery::tickInventory);

I will look later that

Nadwey and others added 5 commits July 14, 2025 11:00
…o feat/folia-support

# Conflicts:
#	bukkit/src/main/java/dev/jsinco/brewery/bukkit/breweries/BukkitCauldron.java
#	bukkit/src/main/java/dev/jsinco/brewery/bukkit/effect/event/NamedDrunkEventExecutor.java
Add runFolia task to BreweryTeam#77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants