Added force-dropqueue

This commit is contained in:
Auxilor 2020-12-19 19:26:23 +00:00
parent 47f84d4124
commit 70a596ee1e
2 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal; package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.config.ConfigManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound; import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound;
@ -33,14 +34,21 @@ public class Telekinesis extends EcoEnchant {
); );
} }
private static boolean always = false;
// START OF LISTENERS // START OF LISTENERS
@Override
protected void postUpdate() {
always = ConfigManager.getConfig().getBool("drops.force-dropqueue");
}
// For block drops // For block drops
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void telekinesisDropItem(BlockDropItemEvent event) { public void telekinesisDropItem(BlockDropItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!EnchantChecks.mainhand(player, this)) return; if(!always && !EnchantChecks.mainhand(player, this)) return;
if(this.getDisabledWorldNames().contains(player.getWorld().getName())) return; if(this.getDisabledWorldNames().contains(player.getWorld().getName())) return;
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -57,7 +65,6 @@ public class Telekinesis extends EcoEnchant {
new DropQueue(player) new DropQueue(player)
.setLocation(block.getLocation()) .setLocation(block.getLocation())
.addItems(drops) .addItems(drops)
.forceTelekinesis()
.push(); .push();
} }
@ -67,7 +74,7 @@ public class Telekinesis extends EcoEnchant {
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getBlock(); Block block = event.getBlock();
if (!EnchantChecks.mainhand(player, this)) return; if(!always && !EnchantChecks.mainhand(player, this)) return;
if(this.getDisabledWorlds().contains(player.getWorld())) return; if(this.getDisabledWorlds().contains(player.getWorld())) return;
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)
@ -83,7 +90,6 @@ public class Telekinesis extends EcoEnchant {
new DropQueue(player) new DropQueue(player)
.setLocation(block.getLocation()) .setLocation(block.getLocation())
.addXP(event.getExpToDrop()) .addXP(event.getExpToDrop())
.forceTelekinesis()
.push(); .push();
event.setExpToDrop(0); event.setExpToDrop(0);

View File

@ -105,3 +105,7 @@ drops:
# Instead of directly dropping all drops and xp, some intensive enchantments (eg Telekinesis and Infernal Touch) will push to a collated queue. # Instead of directly dropping all drops and xp, some intensive enchantments (eg Telekinesis and Infernal Touch) will push to a collated queue.
# At the end of each tick, the queue will be pushed rather than pushing on every drop creation # At the end of each tick, the queue will be pushed rather than pushing on every drop creation
# This will massively improve mining performance on servers, however it is experimental and may not function correctly. # This will massively improve mining performance on servers, however it is experimental and may not function correctly.
force-dropqueue: true
# When combined with collate, this massively reduces calls to getItemMeta, which can hurt performance when many enchants are on an item.
# Without collate, the number of calls may be increased - which will further hurt performance
# Enabling this option makes all drops go through telekinesis listeners