mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Use a copy of the block list in BlockExplodeEvent for the fake EntityExplodeEvent. Fixes #356
The blockList() call returns the actual List<Block> object in the explode event, which means it'll be shared between the the fake event and the original event. As a result, the call to blockList().clear() will clear the shared list, and the following call to blockList().addAll(fake.blockList()) results in trying to add the empty list to itself. This commit makes sure to copy the original event's block list before sending it to the fake event.
This commit is contained in:
parent
c66321ec78
commit
48a85a7e85
@ -1,6 +1,7 @@
|
||||
package com.garbagemule.MobArena.listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -20,6 +21,9 @@ import com.garbagemule.MobArena.leaderboards.Stats;
|
||||
import com.garbagemule.MobArena.util.VersionChecker;
|
||||
import com.garbagemule.MobArena.util.inventory.InventoryManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The point of this class is to simply redirect all events to each arena's
|
||||
* own listener(s).
|
||||
@ -165,8 +169,11 @@ public class MAGlobalListener implements Listener
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void blockExplode(BlockExplodeEvent event) {
|
||||
// Create a copy of the block list so we can clear and re-add
|
||||
List<Block> blocks = new ArrayList<>(event.blockList());
|
||||
|
||||
// Account for Spigot's messy extra event
|
||||
EntityExplodeEvent fake = new EntityExplodeEvent(null, event.getBlock().getLocation(), event.blockList(), event.getYield());
|
||||
EntityExplodeEvent fake = new EntityExplodeEvent(null, event.getBlock().getLocation(), blocks, event.getYield());
|
||||
entityExplode(fake);
|
||||
|
||||
// Copy the values over
|
||||
|
Loading…
Reference in New Issue
Block a user