Fixed FastCollatedDropQueue breaking on /ecoreload
This commit is contained in:
@@ -399,5 +399,7 @@ public class Loader {
|
||||
}
|
||||
}, 1);
|
||||
}));
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), FastCollatedDropQueue.RUNNABLE, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -21,6 +22,19 @@ import java.util.Map;
|
||||
public class FastCollatedDropQueue extends InternalDropQueue {
|
||||
private static boolean collate = false;
|
||||
private static final HashMap<Player, CollatedDrops> COLLATED_MAP = new HashMap<>();
|
||||
public static final Runnable RUNNABLE = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Map.Entry<Player, CollatedDrops> entry : COLLATED_MAP.entrySet()) {
|
||||
new InternalDropQueue(entry.getKey())
|
||||
.setLocation(entry.getValue().getLocation())
|
||||
.addItems(entry.getValue().getDrops())
|
||||
.addXP(entry.getValue().getXp())
|
||||
.push();
|
||||
}
|
||||
COLLATED_MAP.clear();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create {@link DropQueue} linked to player
|
||||
@@ -47,17 +61,7 @@ public class FastCollatedDropQueue extends InternalDropQueue {
|
||||
}
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), () -> {
|
||||
for (Map.Entry<Player, CollatedDrops> entry : COLLATED_MAP.entrySet()) {
|
||||
new InternalDropQueue(entry.getKey())
|
||||
.setLocation(entry.getValue().getLocation())
|
||||
.addItems(entry.getValue().getDrops())
|
||||
.addXP(entry.getValue().getXp())
|
||||
.push();
|
||||
}
|
||||
COLLATED_MAP.clear();
|
||||
}, 0, 1);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), RUNNABLE, 0, 1);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.willfp.ecoenchants.util.internal.drops;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import com.willfp.ecoenchants.util.internal.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
@@ -126,6 +127,7 @@ public class InternalDropQueue implements AbstractDropQueue {
|
||||
public void push() {
|
||||
if(!hasTelekinesis) hasTelekinesis = EnchantChecks.item(item, EcoEnchants.TELEKINESIS);
|
||||
if(hasTelekinesis && !EcoEnchants.TELEKINESIS.isEnabled()) hasTelekinesis = false;
|
||||
Logger.info("1");
|
||||
|
||||
World world = loc.getWorld();
|
||||
assert world != null;
|
||||
@@ -150,6 +152,7 @@ public class InternalDropQueue implements AbstractDropQueue {
|
||||
}
|
||||
} else {
|
||||
for (ItemStack drop : items) {
|
||||
Logger.info(drop + "");
|
||||
world.dropItem(loc, drop).setVelocity(new Vector());
|
||||
}
|
||||
if (xp > 0) {
|
||||
|
||||
Reference in New Issue
Block a user