mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Fixed /giverandombook
This commit is contained in:
parent
a9098ee4c0
commit
a650c48dae
@ -49,7 +49,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.willfp:eco:5.0.0'
|
compileOnly 'com.willfp:eco:5.0.2'
|
||||||
|
|
||||||
compileOnly 'org.jetbrains:annotations:19.0.0'
|
compileOnly 'org.jetbrains:annotations:19.0.0'
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.willfp.eco.core.command.AbstractTabCompleter;
|
|||||||
import com.willfp.eco.util.NumberUtils;
|
import com.willfp.eco.util.NumberUtils;
|
||||||
import com.willfp.ecoenchants.command.tabcompleters.TabCompleterRandomEnchant;
|
import com.willfp.ecoenchants.command.tabcompleters.TabCompleterRandomEnchant;
|
||||||
import com.willfp.ecoenchants.display.EnchantmentCache;
|
import com.willfp.ecoenchants.display.EnchantmentCache;
|
||||||
|
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -15,7 +16,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CommandGiverandombook extends AbstractCommand {
|
public class CommandGiverandombook extends AbstractCommand {
|
||||||
/**
|
/**
|
||||||
@ -48,7 +51,13 @@ public class CommandGiverandombook extends AbstractCommand {
|
|||||||
|
|
||||||
ItemStack itemStack = new ItemStack(Material.ENCHANTED_BOOK);
|
ItemStack itemStack = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta();
|
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta();
|
||||||
Enchantment enchantment = Enchantment.values()[NumberUtils.randInt(0, Enchantment.values().length - 1)];
|
List<Enchantment> allowed = Arrays.stream(Enchantment.values()).filter(enchantment -> {
|
||||||
|
if (enchantment instanceof EcoEnchant) {
|
||||||
|
return ((EcoEnchant) enchantment).isEnabled();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
Enchantment enchantment = allowed.get(NumberUtils.randInt(0, allowed.size() - 1));
|
||||||
int level = NumberUtils.randInt(1, enchantment.getMaxLevel());
|
int level = NumberUtils.randInt(1, enchantment.getMaxLevel());
|
||||||
meta.addStoredEnchant(enchantment, level, true);
|
meta.addStoredEnchant(enchantment, level, true);
|
||||||
itemStack.setItemMeta(meta);
|
itemStack.setItemMeta(meta);
|
||||||
|
Loading…
Reference in New Issue
Block a user