fixed error in weapon command as args isnt joined

This commit is contained in:
night0721 2022-07-11 09:47:03 +01:00
parent c6a489cc01
commit e46bc98564

View file

@ -2,6 +2,7 @@ package com.night.nullvalkyrie.commands;
import com.night.nullvalkyrie.Enchantments.EnchantmentHandler;
import com.night.nullvalkyrie.Items.CustomItemManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
@ -30,9 +31,9 @@ public class WeaponCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
System.out.println(args[0]);
String name = String.join(" ", args);
Player player = (Player) sender;
if(args[0].equalsIgnoreCase("Snow Gun")) {
if(name.equalsIgnoreCase("Snow Gun")) {
ItemStack hoe = new ItemStack(Material.DIAMOND_HOE);
hoe.addUnsafeEnchantment(EnchantmentHandler.ThunderBolt, 5);
hoe.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
@ -43,7 +44,7 @@ public class WeaponCommand extends Command {
hoe.setItemMeta(hoedata);
player.getInventory().addItem(hoe);
} else if(args[0].equalsIgnoreCase("Grenade")) {
} else if(name.equalsIgnoreCase("Grenade")) {
ItemStack egg = new ItemStack(Material.EGG);
ItemMeta eggdata = egg.getItemMeta();
eggdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade");
@ -51,7 +52,7 @@ public class WeaponCommand extends Command {
eggdata.setLore(Arrays.asList(ChatColor.GOLD + "Boom"));
egg.setItemMeta(eggdata);
player.getInventory().addItem(egg);
} else if(args[0].equalsIgnoreCase("Widow Sword")) {
} else if(name.equalsIgnoreCase("Widow Sword")) {
player.getInventory().addItem(CustomItemManager.WidowSword);
}
}