- refactored a bit
- added a steven sword
This commit is contained in:
@@ -1,32 +1,75 @@
|
||||
package fantasypvp.kand.items;
|
||||
|
||||
import fantasypvp.kand.util.attribute_gear.TierVI;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class LightningGear {
|
||||
public static ItemStack lightning_sword;
|
||||
public class LightningGear implements Listener, CommandExecutor {
|
||||
|
||||
public static void init() {
|
||||
lightningSword();
|
||||
@EventHandler
|
||||
public static void onEntityDamageByEntity(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
|
||||
|
||||
if (event.getDamager() instanceof org.bukkit.entity.Player) {
|
||||
Player player = (Player) event.getDamager();
|
||||
// check if the player is using the lightning sword
|
||||
|
||||
try {
|
||||
player.getInventory().getItemInMainHand().getItemMeta().getLore().toString();
|
||||
} catch (NullPointerException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getInventory().getItemInMainHand().getItemMeta().getLore().toString().contains(ChatColor.YELLOW + "All Who Oppose Shall Be SMITTEN!")) {
|
||||
// check if hit is critical
|
||||
if (player.getFallDistance() > 0.0F && !player.isInsideVehicle() && !player.isGliding() && !player.isSwimming() && !player.isClimbing() && player.getAttackCooldown() == 1.0F) {
|
||||
player.getWorld().strikeLightningEffect(event.getEntity().getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void lightningSword() {
|
||||
@Override
|
||||
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players can use this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(player.hasPermission("kand.lightning_sword")) {
|
||||
if (command.getName().equalsIgnoreCase("lightning_sword")) {
|
||||
player.getInventory().addItem(lightningSword());
|
||||
}
|
||||
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"You don't have permission to run this command.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack lightningSword() {
|
||||
ItemStack item = new ItemStack(Material.NETHERITE_SWORD, 1);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Lightning Sword");
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§7All who oppose shall be smitten");
|
||||
lore.add(ChatColor.YELLOW + "All Who Oppose Shall Be SMITTEN!");
|
||||
meta.setLore(lore);
|
||||
// set damage to 12 when in main hand
|
||||
UUID uuid = UUID.randomUUID();
|
||||
@@ -46,7 +89,6 @@ public class LightningGear {
|
||||
EquipmentSlot.HAND
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
lightning_sword = item;
|
||||
|
||||
// shaped recipe
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("lightning_sword"), item);
|
||||
@@ -59,6 +101,7 @@ public class LightningGear {
|
||||
recipe.setIngredient('H', Material.LIGHTNING_ROD);
|
||||
|
||||
getServer().addRecipe(recipe);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user