refactored

This commit is contained in:
FantasyPvP
2024-05-03 00:05:43 +01:00
parent 13458a0520
commit b62b5c23a4
5 changed files with 88 additions and 63 deletions
@@ -3,7 +3,7 @@ package fantasypvp.kand_smp;
import fantasypvp.kand_smp.commands.CmdLightningSword;
import fantasypvp.kand_smp.commands.CmdTeleportSpawn;
import fantasypvp.kand_smp.events.Events;
import fantasypvp.kand_smp.items.Items;
import fantasypvp.kand_smp.items.LightningGear;
import org.bukkit.plugin.java.JavaPlugin;
public final class Kand_smp extends JavaPlugin {
@@ -11,7 +11,7 @@ public final class Kand_smp extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
Items.init();
LightningGear.init();
// register listeners
getServer().getPluginManager().registerEvents(new Events(), this);
@@ -1,6 +1,6 @@
package fantasypvp.kand_smp.commands;
import fantasypvp.kand_smp.items.Items;
import fantasypvp.kand_smp.items.LightningGear;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
@@ -15,7 +15,7 @@ public class CmdLightningSword implements CommandExecutor {
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("lightning_sword")) {
player.getInventory().addItem(Items.lightning_sword);
player.getInventory().addItem(LightningGear.lightning_sword);
}
return true;
@@ -0,0 +1,79 @@
package fantasypvp.kand_smp.items;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import static org.bukkit.Bukkit.getServer;
public class LightningGear {
public static ItemStack lightning_sword;
public static void init() {
lightningSword();
}
private static void 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");
meta.setLore(lore);
// set damage to 12 when in main hand
meta.addAttributeModifier(
Attribute.GENERIC_ATTACK_DAMAGE,
new AttributeModifier(
"generic.attackDamage",
12,
AttributeModifier.Operation.ADD_NUMBER
)
);
item.setItemMeta(meta);
lightning_sword = item;
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
// shaped recipe
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("lightning_sword"), item);
recipe.shape(
" X",
" X ",
"H "
);
recipe.setIngredient('X', Material.NETHER_STAR);
recipe.setIngredient('H', Material.LIGHTNING_ROD);
getServer().addRecipe(recipe);
}
}
@@ -12,13 +12,12 @@ import java.util.List;
import static org.bukkit.Bukkit.getServer;
public class Items {
public class TrueNetherite {
public static ItemStack true_netherite_sword;
public static ItemStack true_netherite_helmet;
public static ItemStack true_netherite_chestplate;
public static ItemStack true_netherite_leggings;
public static ItemStack true_netherite_boots;
public static ItemStack lightning_sword;
public static void init() {
trueNetheriteSword();
@@ -26,41 +25,6 @@ public class Items {
trueNetheriteChestplate();
trueNetheriteLeggings();
trueNetheriteBoots();
lightningSword();
}
private static void 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");
meta.setLore(lore);
// set damage to 12 when in main hand
meta.addAttributeModifier(
Attribute.GENERIC_ATTACK_DAMAGE,
new AttributeModifier(
"generic.attackDamage",
12,
AttributeModifier.Operation.ADD_NUMBER
)
);
item.setItemMeta(meta);
lightning_sword = item;
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
// shaped recipe
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("lightning_sword"), item);
recipe.shape(
" X",
" X ",
"H "
);
recipe.setIngredient('X', Material.NETHER_STAR);
recipe.setIngredient('H', Material.LIGHTNING_ROD);
getServer().addRecipe(recipe);
}
private static void trueNetheriteSword() {
@@ -195,25 +159,3 @@ public class Items {
}
@@ -0,0 +1,4 @@
package fantasypvp.kand_smp.items;
public class Witherite {
}