mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-29 16:15:17 +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 boolean hasTelekinesis = false;
|
||||||
private ItemStack item;
|
private ItemStack item;
|
||||||
|
|
||||||
|
private static boolean useOrb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create {@link DropQueue} linked to player
|
* Create {@link DropQueue} linked to player
|
||||||
*
|
*
|
||||||
@ -116,25 +118,22 @@ public class DropQueue {
|
|||||||
* Push the queue
|
* Push the queue
|
||||||
*/
|
*/
|
||||||
public void push() {
|
public void push() {
|
||||||
if (!hasTelekinesis) hasTelekinesis = EnchantChecks.item(item, EcoEnchants.TELEKINESIS);
|
if(!hasTelekinesis) hasTelekinesis = EnchantChecks.item(item, EcoEnchants.TELEKINESIS);
|
||||||
if (hasTelekinesis && !EcoEnchants.TELEKINESIS.isEnabled()) hasTelekinesis = false;
|
if(hasTelekinesis && !EcoEnchants.TELEKINESIS.isEnabled()) hasTelekinesis = false;
|
||||||
|
|
||||||
|
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld();
|
||||||
assert world != null;
|
assert world != null;
|
||||||
|
|
||||||
if (hasTelekinesis) {
|
if(hasTelekinesis) {
|
||||||
for (ItemStack drop : items) {
|
HashMap<Integer, ItemStack> leftover = player.getInventory().addItem(items.toArray(new ItemStack[]{}));
|
||||||
HashMap<Integer, ItemStack> nope = player.getInventory().addItem(drop);
|
for(ItemStack drop : leftover.values()) {
|
||||||
nope.forEach(((integer, itemStack) -> {
|
world.dropItemNaturally(loc.add(0.5, 0, 0.5), drop).setVelocity(new Vector());
|
||||||
world.dropItemNaturally(loc.add(0.5, 0, 0.5), itemStack).setVelocity(new Vector());
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
if (xp > 0) {
|
if (xp > 0) {
|
||||||
PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, xp);
|
PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, xp);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (EcoEnchants.TELEKINESIS.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-orb")) {
|
if (useOrb) {
|
||||||
ExperienceOrb orb = (ExperienceOrb) player.getWorld().spawnEntity(player.getLocation().add(0, 0.2, 0), EntityType.EXPERIENCE_ORB);
|
ExperienceOrb orb = (ExperienceOrb) world.spawnEntity(player.getLocation().add(0, 0.2, 0), EntityType.EXPERIENCE_ORB);
|
||||||
orb.setVelocity(new Vector(0, 0, 0));
|
orb.setVelocity(new Vector(0, 0, 0));
|
||||||
orb.setExperience(event.getAmount());
|
orb.setExperience(event.getAmount());
|
||||||
} else {
|
} 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();
|
EnchantmentRarity.update();
|
||||||
EnchantmentTarget.update();
|
EnchantmentTarget.update();
|
||||||
EcoEnchants.update();
|
EcoEnchants.update();
|
||||||
|
DropQueue.update();
|
||||||
EnchantDisplay.update();
|
EnchantDisplay.update();
|
||||||
TabCompleterEnchantinfo.reload();
|
TabCompleterEnchantinfo.reload();
|
||||||
EcoEnchant.EnchantmentType.update();
|
EcoEnchant.EnchantmentType.update();
|
||||||
|
Loading…
Reference in New Issue
Block a user