custom item handler with rarity

This commit is contained in:
night0721 2022-07-12 13:31:53 +01:00
parent ccf9627b79
commit 235fbcc0ce
7 changed files with 372 additions and 267 deletions

View file

@ -6,7 +6,7 @@ import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class EnchantmentHandler { public class EnchantmentManager {
public static final Enchantment ThunderBolt = new CustomEnchantment("thunderbolt", "ThunderBolt", 5); public static final Enchantment ThunderBolt = new CustomEnchantment("thunderbolt", "ThunderBolt", 5);
public static final Enchantment SmeltingTouch = new CustomEnchantment("smelting-touch", "Smelting Touch", 1); public static final Enchantment SmeltingTouch = new CustomEnchantment("smelting-touch", "Smelting Touch", 1);
public static void register() { public static void register() {

View file

@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import java.util.Set; import java.util.Set;
import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig; import static com.night.nullvalkyrie.Items.CustomItem.loadConfig;
public class CustomItemEvents implements Listener { public class CustomItemEvents implements Listener {
@EventHandler @EventHandler

View file

@ -0,0 +1,260 @@
package com.night.nullvalkyrie.Items;
import com.night.nullvalkyrie.Enchantments.EnchantmentManager;
import com.night.nullvalkyrie.Main;
import org.bukkit.Bukkit;
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.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static com.night.nullvalkyrie.Enchantments.EnchantmentManager.ThunderBolt;
public class CustomItem {
private static Main main;
public CustomItem(Main main) {
this.main = main;
if(!main.getDataFolder().exists()) {
main.getDataFolder().mkdir();
}
}
public static ItemStack WidowSword;
public static ItemStack Terminator;
public static ItemStack Grenade;
public static ItemStack SnowGun;
public static ItemStack ExplosiveBow;
public static ItemStack AOTV;
public static ItemStack GrapplingHook;
public static void register() {
createItemDataDirectory("ItemData");
setWidowSword();
setTerminator();
setGrenade();
setSnowGun();
setExplosiveBow();
setAOTV();
setGrapplingHook();
}
public static YamlConfiguration loadConfig(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return YamlConfiguration.loadConfiguration(f);
}
public static File loadFile(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return f;
}
private static void createItemDataDirectory(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
try {
if(!f.mkdir()) {
try {
f.mkdir();
} catch (SecurityException e) {
e.printStackTrace();
}
}
} catch (SecurityException e) {
e.printStackTrace();
}
}
}
private static void setWidowSword() {
YamlConfiguration config = loadConfig("ItemData\\WidowSword.yml");
config.set("zombie", 100);
config.set("skeleton", 100);
config.set("spider", 100);
try {
config.save(loadFile("ItemData\\WidowSword.yml"));
} catch (IOException e) {
e.printStackTrace();
}
int skeletondmg = config.getInt("skeleton");
int zombiedmg = config.getInt("zombie");
int spiderdmg = config.getInt("spider");
ItemStack widow_sword = new ItemStack(Material.STICK);
widow_sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
widow_sword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10);
widow_sword.addUnsafeEnchantment(Enchantment.FIRE_ASPECT,2);
widow_sword.addUnsafeEnchantment(Enchantment.LUCK,5);
widow_sword.addUnsafeEnchantment(ThunderBolt,5);
ItemMeta wsMeta = widow_sword.getItemMeta();
wsMeta.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Fabled Widow Sword");
wsMeta.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+100");
lore.add("");
ArrayList<String> enchants = new ArrayList<>();
for (Enchantment enchant : widow_sword.getEnchantments().keySet()) {
List<String> splitted = Arrays.asList(Arrays.asList(enchant.getKey().toString().split(":")).get(1).split("_"));
StringBuilder name = new StringBuilder();
for (String i : splitted) {
String s = i.substring(0, 1).toUpperCase() + i.substring(1);
if(splitted.size() > 1) {
if(i.equals(splitted.get(splitted.size() - 1))) {
name.append(s);
} else {
name.append(s);
name.append(" ");
}
} else name.append(s);
}
enchants.add(name + " " + widow_sword.getEnchantmentLevel(enchant));
}
lore.add(ChatColor.BLUE + String.join(", ", enchants));
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: Damage Multiplier");
lore.add(ChatColor.GRAY + "Damage dealt to mobs will be multiplied");
lore.add(ChatColor.RED + "Zombie +" + zombiedmg + "%");
lore.add(ChatColor.RED + "Skeleton +" + skeletondmg + "%");
lore.add(ChatColor.RED + "Spider +" + spiderdmg + "%");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
wsMeta.setLore(lore);
AttributeModifier dmg = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 100, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
wsMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, dmg);
wsMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
widow_sword.setItemMeta(wsMeta);
WidowSword = widow_sword;
ShapedRecipe wither_sword_recipe = new ShapedRecipe(NamespacedKey.minecraft("widow_sword"), widow_sword);
wither_sword_recipe.shape(" A ", " A "," B ");
wither_sword_recipe.setIngredient('A', Material.IRON_INGOT);
wither_sword_recipe.setIngredient('B', Material.STICK);
Bukkit.addRecipe(wither_sword_recipe);
}
private static void setTerminator() {
HashMap<String, List<String>> d = new HashMap<>();
List<String> pr = new ArrayList<>();
pr.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+50");
d.put("properties", pr);
List<String> ia = new ArrayList<>();
ia.add(ChatColor.GOLD + "Item Ability: Triple Shot");
ia.add(ChatColor.GRAY + "Shoot three arrow at one time");
d.put("ability", ia);
HashMap<Enchantment, Integer> e = new HashMap<>();
e.put(Enchantment.DAMAGE_ALL, 20);
e.put(Enchantment.LOOT_BONUS_MOBS, 10);
e.put(ThunderBolt,5);
Terminator = main.getCustomItemManager().register(Material.BOW, "Terminator",Rarity.MYTHIC, d, e,50.0,0.05);
}
private static void setGrenade() {
ItemStack egg = new ItemStack(Material.EGG);
ItemMeta eggdata = egg.getItemMeta();
eggdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade");
eggdata.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Item Ability: Throw a TNT ");
lore.add(ChatColor.GRAY + "Shoot TNT with 25x more power!");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
eggdata.setLore(lore);
eggdata.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
egg.setItemMeta(eggdata);
Grenade = egg;
}
private static void setSnowGun() {
ItemStack hoe = new ItemStack(Material.DIAMOND_HOE);
hoe.addUnsafeEnchantment(EnchantmentManager.ThunderBolt, 5);
hoe.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
ItemMeta hoedata = hoe.getItemMeta();
hoedata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "SnowGun");
hoedata.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Item Ability: Shoot Snowball");
lore.add(ChatColor.GRAY + "Shoot snowball!");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
hoedata.setLore(lore);
hoedata.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
hoe.setItemMeta(hoedata);
SnowGun = hoe;
}
private static void setExplosiveBow() {
ItemStack i = new ItemStack(Material.BOW);
i.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
i.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10);
i.addUnsafeEnchantment(ThunderBolt,5);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.GOLD + "Explosive Bow");
im.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: Explosive Shot");
lore.add(ChatColor.GRAY + "Shoot explosive arrows");
lore.add("");
lore.add(ChatColor.GOLD.toString() + ChatColor.BOLD + "LEGENDARY");
im.setLore(lore);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im);
ExplosiveBow = i;
}
private static void setAOTV() {
ItemStack i = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.DARK_PURPLE + "Aspect of The Void");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+100");
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: Instant Teleport");
lore.add(ChatColor.GRAY + "Teleport 12 blocks ahead");
lore.add("");
lore.add(ChatColor.DARK_PURPLE.toString() + ChatColor.BOLD + "EPIC");
im.setLore(lore);
im.setUnbreakable(true);
AttributeModifier dmg = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 25, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
AttributeModifier speed = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", 0.2, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, dmg);
im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, speed);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im);
AOTV = i;
}
private static void setGrapplingHook() {
ItemStack i = new ItemStack(Material.FISHING_ROD, 1);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.WHITE + "Grappling Hook");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "I believe I can fly...");
lore.add("");
lore.add(ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON");
im.setLore(lore);
im.setUnbreakable(true);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im);
GrapplingHook = i;
}
}

View file

@ -1,267 +1,64 @@
package com.night.nullvalkyrie.Items; package com.night.nullvalkyrie.Items;
import com.night.nullvalkyrie.Enchantments.EnchantmentHandler;
import com.night.nullvalkyrie.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.io.File; import java.util.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static com.night.nullvalkyrie.Enchantments.EnchantmentHandler.ThunderBolt;
public class CustomItemManager { public class CustomItemManager {
private static Main main; public ItemStack register(Material item, String name, Rarity rarity, HashMap<String, List<String>> lore, HashMap<Enchantment, Integer> enchantment, double damage, double movespeed) {
public CustomItemManager(Main main) { ItemStack i = new ItemStack(item);
this.main = main; for(Enchantment e : enchantment.keySet()) {
if(!main.getDataFolder().exists()) { i.addUnsafeEnchantment(e, enchantment.get(e));
main.getDataFolder().mkdir();
} }
ItemMeta im = i.getItemMeta();
im.setDisplayName(rarity.getColor() + name);
im.setUnbreakable(true);
ArrayList<String> l = new ArrayList<>();
for(String ll : lore.get("properties")) {
l.add(ll);
} }
public static ItemStack WidowSword; l.add("");
public static ItemStack Terminator; ArrayList<String> e = new ArrayList<>();
public static ItemStack Grenade; for (Enchantment ee : i.getEnchantments().keySet()) {
public static ItemStack SnowGun; List<String> splitted = Arrays.asList(Arrays.asList(ee.getKey().toString().split(":")).get(1).split("_"));
public static ItemStack ExplosiveBow; StringBuilder n = new StringBuilder();
public static ItemStack AOTV; for (String ii : splitted) {
public static ItemStack GrapplingHook; String s = ii.substring(0, 1).toUpperCase() + ii.substring(1);
public static void register() {
createItemDataDirectory("ItemData");
setWidowSword();
setTerminator();
setGrenade();
setSnowGun();
setExplosiveBow();
setAOTV();
setGrapplingHook();
}
public static YamlConfiguration loadConfig(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return YamlConfiguration.loadConfiguration(f);
}
public static File loadFile(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return f;
}
private static void createItemDataDirectory(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
try {
if(!f.mkdir()) {
try {
f.mkdir();
} catch (SecurityException e) {
e.printStackTrace();
}
}
} catch (SecurityException e) {
e.printStackTrace();
}
}
}
private static void setWidowSword() {
YamlConfiguration config = loadConfig("ItemData\\WidowSword.yml");
config.set("zombie", 100);
config.set("skeleton", 100);
config.set("spider", 100);
try {
config.save(loadFile("ItemData\\WidowSword.yml"));
} catch (IOException e) {
e.printStackTrace();
}
int skeletondmg = config.getInt("skeleton");
int zombiedmg = config.getInt("zombie");
int spiderdmg = config.getInt("spider");
ItemStack widow_sword = new ItemStack(Material.STICK);
widow_sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
widow_sword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10);
widow_sword.addUnsafeEnchantment(Enchantment.FIRE_ASPECT,2);
widow_sword.addUnsafeEnchantment(Enchantment.LUCK,5);
widow_sword.addUnsafeEnchantment(ThunderBolt,5);
ItemMeta wsMeta = widow_sword.getItemMeta();
wsMeta.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Fabled Widow Sword");
wsMeta.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+100");
lore.add("");
ArrayList<String> enchants = new ArrayList<>();
for (Enchantment enchant : widow_sword.getEnchantments().keySet()) {
List<String> splitted = Arrays.asList(Arrays.asList(enchant.getKey().toString().split(":")).get(1).split("_"));
StringBuilder name = new StringBuilder();
for (String i : splitted) {
String s = i.substring(0, 1).toUpperCase() + i.substring(1);
if(splitted.size() > 1) { if(splitted.size() > 1) {
if(i.equals(splitted.get(splitted.size() - 1))) { if(ii.equals(splitted.get(splitted.size() - 1))) {
name.append(s); n.append(s);
} else { } else {
name.append(s); n.append(s);
name.append(" "); n.append(" ");
} }
} else name.append(s); } else n.append(s);
} }
enchants.add(name + " " + widow_sword.getEnchantmentLevel(enchant)); e.add(n + " " + i.getEnchantmentLevel(ee));
} }
lore.add(ChatColor.BLUE + String.join(", ", enchants)); l.add(ChatColor.BLUE + String.join(", ", e));
lore.add(""); l.add("");
lore.add(ChatColor.GOLD + "Item Ability: Damage Multiplier"); for(String ll : lore.get("ability")) {
lore.add(ChatColor.GRAY + "Damage dealt to mobs will be multiplied"); l.add(ll);
lore.add(ChatColor.RED + "Zombie +" + zombiedmg + "%");
lore.add(ChatColor.RED + "Skeleton +" + skeletondmg + "%");
lore.add(ChatColor.RED + "Spider +" + spiderdmg + "%");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
wsMeta.setLore(lore);
AttributeModifier dmg = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 100, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
wsMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, dmg);
wsMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
widow_sword.setItemMeta(wsMeta);
WidowSword = widow_sword;
ShapedRecipe wither_sword_recipe = new ShapedRecipe(NamespacedKey.minecraft("widow_sword"), widow_sword);
wither_sword_recipe.shape(" A ", " A "," B ");
wither_sword_recipe.setIngredient('A', Material.IRON_INGOT);
wither_sword_recipe.setIngredient('B', Material.STICK);
Bukkit.addRecipe(wither_sword_recipe);
} }
private static void setTerminator() { l.add("");
ItemStack terminator = new ItemStack(Material.BOW); l.add(rarity.getDisplay());
terminator.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20); im.setLore(l);
terminator.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); AttributeModifier d = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", damage, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
terminator.addUnsafeEnchantment(ThunderBolt,5); im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, d);
ItemMeta terminatorMeta = terminator.getItemMeta(); AttributeModifier s = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", movespeed, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
terminatorMeta.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Terminator"); im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, s);
terminatorMeta.setUnbreakable(true); im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
ArrayList<String> lore = new ArrayList<>(); i.setItemMeta(im);
lore.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+50");
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: Triple Shot");
lore.add(ChatColor.GRAY + "Shoot three arrow at one time");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
terminatorMeta.setLore(lore);
terminatorMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
terminator.setItemMeta(terminatorMeta);
Terminator = terminator;
}
private static void setGrenade() {
ItemStack egg = new ItemStack(Material.EGG);
ItemMeta eggdata = egg.getItemMeta();
eggdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade");
eggdata.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Item Ability: Throw a TNT ");
lore.add(ChatColor.GRAY + "Shoot TNT with 25x more power!");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
eggdata.setLore(lore);
eggdata.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
egg.setItemMeta(eggdata);
Grenade = egg;
}
private static void setSnowGun() {
ItemStack hoe = new ItemStack(Material.DIAMOND_HOE);
hoe.addUnsafeEnchantment(EnchantmentHandler.ThunderBolt, 5);
hoe.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
ItemMeta hoedata = hoe.getItemMeta();
hoedata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "SnowGun");
hoedata.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Item Ability: Shoot Snowball");
lore.add(ChatColor.GRAY + "Shoot snowball!");
lore.add("");
lore.add(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC");
hoedata.setLore(lore);
hoedata.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
hoe.setItemMeta(hoedata);
SnowGun = hoe; return i;
}
private static void setExplosiveBow() {
ItemStack i = new ItemStack(Material.BOW);
i.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20);
i.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10);
i.addUnsafeEnchantment(ThunderBolt,5);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.GOLD + "Explosive Bow");
im.setUnbreakable(true);
ArrayList<String> lore = new ArrayList<>();
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: Explosive Shot");
lore.add(ChatColor.GRAY + "Shoot explosive arrows");
lore.add("");
lore.add(ChatColor.GOLD.toString() + ChatColor.BOLD + "LEGENDARY");
im.setLore(lore);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im);
ExplosiveBow = i;
}
private static void setAOTV() {
ItemStack i = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.DARK_PURPLE + "Aspect of The Void");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+100");
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: Instant Teleport");
lore.add(ChatColor.GRAY + "Teleport 12 blocks ahead");
lore.add("");
lore.add(ChatColor.DARK_PURPLE.toString() + ChatColor.BOLD + "EPIC");
im.setLore(lore);
im.setUnbreakable(true);
AttributeModifier dmg = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 25, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
AttributeModifier speed = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", 0.2, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, dmg);
im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, speed);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im);
AOTV = i;
}
private static void setGrapplingHook() {
ItemStack i = new ItemStack(Material.FISHING_ROD, 1);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.WHITE + "Grappling Hook");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "I believe I can fly...");
lore.add("");
lore.add(ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON");
im.setLore(lore);
im.setUnbreakable(true);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im);
GrapplingHook = i;
} }
} }

View file

@ -0,0 +1,25 @@
package com.night.nullvalkyrie.Items;
import org.bukkit.ChatColor;
public enum Rarity {
COMMON(ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON", ChatColor.WHITE.toString()),
UNCOMMON(net.md_5.bungee.api.ChatColor.of("#31ff09").toString() + ChatColor.BOLD + "UNCOMMON", net.md_5.bungee.api.ChatColor.of("#31ff09").toString()),
RARE(net.md_5.bungee.api.ChatColor.of("#2f57ae").toString() + ChatColor.BOLD + "RARE", net.md_5.bungee.api.ChatColor.of("#2f57ae").toString()),
EPIC(net.md_5.bungee.api.ChatColor.of("#b201b2").toString() + ChatColor.BOLD + "EPIC", net.md_5.bungee.api.ChatColor.of("#b201b2").toString()),
LEGENDARY(net.md_5.bungee.api.ChatColor.of("#ffa21b").toString() + ChatColor.BOLD + "LEGENDARY", net.md_5.bungee.api.ChatColor.of("#ffa21b").toString()),
MYTHIC(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC", net.md_5.bungee.api.ChatColor.of("#ff23ff").toString()),
ULTRA(ChatColor.BLACK.toString() + ChatColor.BOLD + "ULTRA", ChatColor.BLACK.toString()),
GRAND(net.md_5.bungee.api.ChatColor.of("#ffc509").toString() + ChatColor.BOLD + "GRAND", net.md_5.bungee.api.ChatColor.of("#ffc509").toString());
private String display;
private String color;
Rarity(String display, String color) {
this.display = display;
this.color = color;
}
public String getDisplay() {
return display;
}
public String getColor() {
return color;
}
}

View file

@ -1,8 +1,9 @@
package com.night.nullvalkyrie; package com.night.nullvalkyrie;
import com.night.nullvalkyrie.Chests.MenuListener; import com.night.nullvalkyrie.Chests.MenuListener;
import com.night.nullvalkyrie.Enchantments.EnchantmentHandler; import com.night.nullvalkyrie.Enchantments.EnchantmentManager;
import com.night.nullvalkyrie.Events.CustomItemEvents; import com.night.nullvalkyrie.Events.CustomItemEvents;
import com.night.nullvalkyrie.Items.CustomItem;
import com.night.nullvalkyrie.Items.CustomItemManager; import com.night.nullvalkyrie.Items.CustomItemManager;
import com.night.nullvalkyrie.Rank.*; import com.night.nullvalkyrie.Rank.*;
import com.night.nullvalkyrie.Util.Util; import com.night.nullvalkyrie.Util.Util;
@ -13,12 +14,8 @@ import org.bukkit.*;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar; import org.bukkit.boss.BossBar;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -31,17 +28,42 @@ public final class Main extends JavaPlugin implements Listener {
private NameTagManager nameTagManager; private NameTagManager nameTagManager;
private SideBarManager sideBarManager; private SideBarManager sideBarManager;
private BelowNameManager belowNameManager; private BelowNameManager belowNameManager;
private CustomItemManager customItemManager;
private CustomItem customItems;
public RankManager getRankManager() { public RankManager getRankManager() {
return rankManager; return rankManager;
} }
public NameTagManager getNameTagManager() { return nameTagManager; }
public SideBarManager getSideBarManager() { return sideBarManager; } public NameTagManager getNameTagManager() {
public BelowNameManager getBelowNameManager() { return belowNameManager; } return nameTagManager;
}
public SideBarManager getSideBarManager() {
return sideBarManager;
}
public BelowNameManager getBelowNameManager() {
return belowNameManager;
}
public CustomItemManager getCustomItemManager() {
return customItemManager;
}
@Override @Override
public void onEnable() { public void onEnable() {
new VanishCommand();new TestCommand();new AnvilCommand();new ArmorCommand();new MenuCommand();new RankCommand(this); new VanishCommand();
new MessageCommand();new HologramCommand();new CraftCommand();new EnchantingCommand();new SpawnCommand();new WeaponCommand(); new TestCommand();
new AnvilCommand();
new ArmorCommand();
new MenuCommand();
new RankCommand(this);
new MessageCommand();
new HologramCommand();
new CraftCommand();
new EnchantingCommand();
new SpawnCommand();
new WeaponCommand();
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12); bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new MenuListener(), this); Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
@ -51,15 +73,16 @@ public final class Main extends JavaPlugin implements Listener {
rankManager = new RankManager(this); rankManager = new RankManager(this);
sideBarManager = new SideBarManager(this); sideBarManager = new SideBarManager(this);
belowNameManager = new BelowNameManager(); belowNameManager = new BelowNameManager();
new CustomItemManager(this); customItemManager = new CustomItemManager();
CustomItemManager.register(); customItems = new CustomItem(this);
EnchantmentHandler.register(); customItems.register();
EnchantmentManager.register();
} }
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20); e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20);
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER")); e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
bossbar.addPlayer(e.getPlayer()); bossbar.addPlayer(e.getPlayer());
@ -70,7 +93,7 @@ public final class Main extends JavaPlugin implements Listener {
public void onPing(ServerListPingEvent e) { public void onPing(ServerListPingEvent e) {
e.setMaxPlayers(8964); e.setMaxPlayers(8964);
String s = Util.centerText("Matrix", 45); String s = Util.centerText("Matrix", 45);
String s2 = Util.centerText("Support 1.18 & 1.8.9",45); String s2 = Util.centerText("Support 1.18 & 1.8.9", 45);
e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + "\n" + ChatColor.GOLD + ChatColor.BOLD + s2); e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + "\n" + ChatColor.GOLD + ChatColor.BOLD + s2);
try { try {
e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png"))); e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png")));

View file

@ -1,6 +1,6 @@
package com.night.nullvalkyrie.commands; package com.night.nullvalkyrie.commands;
import com.night.nullvalkyrie.Items.CustomItemManager; import com.night.nullvalkyrie.Items.CustomItem;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
@ -29,19 +29,19 @@ public class WeaponCommand extends Command {
String name = String.join(" ", arg); String name = String.join(" ", arg);
Player player = (Player) sender; Player player = (Player) sender;
if(name.equalsIgnoreCase("Snow Gun")) { if(name.equalsIgnoreCase("Snow Gun")) {
player.getInventory().addItem(CustomItemManager.SnowGun); player.getInventory().addItem(CustomItem.SnowGun);
} else if(name.equalsIgnoreCase("Grenade")) { } else if(name.equalsIgnoreCase("Grenade")) {
player.getInventory().addItem(CustomItemManager.Grenade); player.getInventory().addItem(CustomItem.Grenade);
} else if(name.equalsIgnoreCase("Widow Sword")) { } else if(name.equalsIgnoreCase("Widow Sword")) {
player.getInventory().addItem(CustomItemManager.WidowSword); player.getInventory().addItem(CustomItem.WidowSword);
} else if(name.equalsIgnoreCase("Terminator")) { } else if(name.equalsIgnoreCase("Terminator")) {
player.getInventory().addItem(CustomItemManager.Terminator); player.getInventory().addItem(CustomItem.Terminator);
} else if(name.equalsIgnoreCase("Explosive Bow")) { } else if(name.equalsIgnoreCase("Explosive Bow")) {
player.getInventory().addItem(CustomItemManager.ExplosiveBow); player.getInventory().addItem(CustomItem.ExplosiveBow);
} else if(name.equalsIgnoreCase("AOTV")) { } else if(name.equalsIgnoreCase("AOTV")) {
player.getInventory().addItem(CustomItemManager.AOTV); player.getInventory().addItem(CustomItem.AOTV);
} else if(name.equalsIgnoreCase("Grappling Hook")) { } else if(name.equalsIgnoreCase("Grappling Hook")) {
player.getInventory().addItem(CustomItemManager.GrapplingHook); player.getInventory().addItem(CustomItem.GrapplingHook);
} }
} }