mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
"Optimised" telekinesis
This commit is contained in:
parent
72de863f07
commit
20ab821862
@ -28,6 +28,8 @@ public class DropQueue {
|
||||
private boolean hasTelekinesis = false;
|
||||
private ItemStack item;
|
||||
|
||||
private static boolean useOrb;
|
||||
|
||||
/**
|
||||
* Create {@link DropQueue} linked to player
|
||||
*
|
||||
@ -119,22 +121,19 @@ public class DropQueue {
|
||||
if(!hasTelekinesis) hasTelekinesis = EnchantChecks.item(item, EcoEnchants.TELEKINESIS);
|
||||
if(hasTelekinesis && !EcoEnchants.TELEKINESIS.isEnabled()) hasTelekinesis = false;
|
||||
|
||||
|
||||
World world = loc.getWorld();
|
||||
assert world != null;
|
||||
|
||||
if(hasTelekinesis) {
|
||||
for (ItemStack drop : items) {
|
||||
HashMap<Integer, ItemStack> nope = player.getInventory().addItem(drop);
|
||||
nope.forEach(((integer, itemStack) -> {
|
||||
world.dropItemNaturally(loc.add(0.5, 0, 0.5), itemStack).setVelocity(new Vector());
|
||||
}));
|
||||
HashMap<Integer, ItemStack> leftover = player.getInventory().addItem(items.toArray(new ItemStack[]{}));
|
||||
for(ItemStack drop : leftover.values()) {
|
||||
world.dropItemNaturally(loc.add(0.5, 0, 0.5), drop).setVelocity(new Vector());
|
||||
}
|
||||
if (xp > 0) {
|
||||
PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, xp);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (EcoEnchants.TELEKINESIS.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-orb")) {
|
||||
ExperienceOrb orb = (ExperienceOrb) player.getWorld().spawnEntity(player.getLocation().add(0, 0.2, 0), EntityType.EXPERIENCE_ORB);
|
||||
if (useOrb) {
|
||||
ExperienceOrb orb = (ExperienceOrb) world.spawnEntity(player.getLocation().add(0, 0.2, 0), EntityType.EXPERIENCE_ORB);
|
||||
orb.setVelocity(new Vector(0, 0, 0));
|
||||
orb.setExperience(event.getAmount());
|
||||
} else {
|
||||
@ -152,4 +151,12 @@ public class DropQueue {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
useOrb = EcoEnchants.TELEKINESIS.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-orb");
|
||||
}
|
||||
|
||||
static {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -365,6 +365,7 @@ public class Loader {
|
||||
EnchantmentRarity.update();
|
||||
EnchantmentTarget.update();
|
||||
EcoEnchants.update();
|
||||
DropQueue.update();
|
||||
EnchantDisplay.update();
|
||||
TabCompleterEnchantinfo.reload();
|
||||
EcoEnchant.EnchantmentType.update();
|
||||
|
Loading…
Reference in New Issue
Block a user