Skip to content

Commit

Permalink
address #69 & #70
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsinco committed Dec 18, 2024
1 parent 95ff250 commit 65b04f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/dre/brewery/Barrel.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public static boolean create(Block sign, Player player) {
* @param breaker The Player that broke it, or null if not known
* @param dropItems If the items in the barrels inventory should drop to the ground
*/
@Override
public void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems) {
BarrelRemoveEvent event = new BarrelRemoveEvent(this, dropItems);
// Listened to by LWCBarrel (IntegrationListener)
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/dre/brewery/BarrelBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.BoundingBox;
import com.dre.brewery.utility.MaterialUtil;
import com.dre.brewery.utility.MinecraftVersion;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

/**
* The Blocks that make up a Barrel in the World
Expand All @@ -45,6 +48,15 @@ public BarrelBody(Block spigot, byte signoffset) {
this.spigot = spigot;
this.signoffset = signoffset;
this.bounds = new BoundingBox(0, 0, 0, 0, 0, 0);

if (MinecraftVersion.isFolia()) { // Issues#70
BreweryPlugin.getScheduler().runTask(spigot.getLocation(), () -> {
Block broken = getBrokenBlock(true);
if (broken != null) {
this.remove(broken, null, true);
}
});
}
}

/**
Expand Down Expand Up @@ -201,6 +213,8 @@ public static Block getSpigotOfSign(Block block) {
return block;
}

public abstract void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems);

/**
* Regenerate the Barrel Bounds.
*
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/com/dre/brewery/BreweryPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,29 @@ public void onEnable() {
return;
}

// Load objects
DataManager.loadMiscData(dataManager.getBreweryMiscData());
Barrel.getBarrels().addAll(dataManager.getAllBarrels().stream().filter(Objects::nonNull).toList());
BCauldron.getBcauldrons().putAll(dataManager.getAllCauldrons().stream().filter(Objects::nonNull).collect(Collectors.toMap(BCauldron::getBlock, Function.identity())));
BPlayer.getPlayers().putAll(dataManager.getAllPlayers().stream().filter(Objects::nonNull).collect(Collectors.toMap(BPlayer::getUuid, Function.identity())));
Wakeup.getWakeups().addAll(dataManager.getAllWakeups().stream().filter(Objects::nonNull).toList());
Barrel.getBarrels().addAll(dataManager.getAllBarrels()
.stream()
.filter(Objects::nonNull)
.toList());
BCauldron.getBcauldrons().putAll(dataManager.getAllCauldrons().stream()
.filter(Objects::nonNull)
.collect(Collectors.toMap(
BCauldron::getBlock, Function.identity(),
(existing, replacement) -> replacement // Issues#69
)));
BPlayer.getPlayers().putAll(dataManager.getAllPlayers()
.stream()
.filter(Objects::nonNull)
.collect(Collectors.toMap(
BPlayer::getUuid,
Function.identity()
)));
Wakeup.getWakeups().addAll(dataManager.getAllWakeups()
.stream()
.filter(Objects::nonNull)
.toList());


// Setup Metrics
Expand Down

0 comments on commit 65b04f6

Please sign in to comment.