Skip to content

Commit

Permalink
Release 1.4.3 (#25)
Browse files Browse the repository at this point in the history
* Version 1.4.3

* Remove sync chunk loading when twerking

#24
  • Loading branch information
tastybento authored Jul 17, 2021
1 parent 8bce29e commit de62795
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.4.2</build.version>
<build.version>1.4.3</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.stream.Collectors;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Tag;
Expand All @@ -31,7 +32,7 @@ public class TreeGrowListener implements Listener {
private TwerkingForTrees addon;
private Map<Island, Integer> twerkCount;
private Set<Island> isTwerking;
private Map<Block, Island> plantedTrees;
private Map<Location, Island> plantedTrees;

public TreeGrowListener(@NonNull TwerkingForTrees addon) {
this.addon = addon;
Expand All @@ -46,7 +47,8 @@ protected void runChecker() {
Bukkit.getScheduler().runTaskTimer(addon.getPlugin(), () -> {
isTwerking = twerkCount.entrySet().stream().filter(e -> e.getValue() > addon.getSettings().getMinimumTwerks()).map(Map.Entry::getKey).collect(Collectors.toSet());
twerkCount.clear();
plantedTrees.keySet().removeIf(k -> !Tag.SAPLINGS.isTagged(k.getType()));
// Clear plantedTrees if no one on island is twerking
plantedTrees.values().removeIf(i -> !isTwerking.contains(i));
}
, 0L, 40L);
// Every 20 seconds
Expand All @@ -56,7 +58,7 @@ protected void runChecker() {
.stream()
.filter(e -> isTwerking.contains(e.getValue()))
.map(Map.Entry::getKey)
.forEach(b -> Util.getChunkAtAsync(b.getLocation()).thenRun(() -> growTree(b)))
.forEach(b -> Util.getChunkAtAsync(b).thenRun(() -> growTree(b.getBlock())))
, 10L, 400L);
}

Expand Down Expand Up @@ -119,7 +121,7 @@ private void getNearbySaplings(Player player, Island i) {
for (int z = player.getLocation().getBlockZ() - range ; z <= player.getLocation().getBlockZ() + range; z++) {
Block block = player.getWorld().getBlockAt(x, y, z);
if (Tag.SAPLINGS.isTagged(block.getType())) {
plantedTrees.put(block, i);
plantedTrees.put(block.getLocation(), i);
}
}
}
Expand Down

0 comments on commit de62795

Please sign in to comment.