added custom item handler, when u add a yml file to ItemData folder it will automatically register for you
This commit is contained in:
parent
235fbcc0ce
commit
ecc4990117
8 changed files with 232 additions and 354 deletions
|
@ -7,6 +7,9 @@ import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class EnchantmentManager {
|
public class EnchantmentManager {
|
||||||
|
public EnchantmentManager() {
|
||||||
|
register();
|
||||||
|
}
|
||||||
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() {
|
||||||
|
@ -18,7 +21,6 @@ public class EnchantmentManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void registerEnchantment(Enchantment en) {
|
public static void registerEnchantment(Enchantment en) {
|
||||||
boolean registered = true;
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
Field f = Enchantment.class.getDeclaredField("acceptingNew");
|
Field f = Enchantment.class.getDeclaredField("acceptingNew");
|
||||||
|
@ -29,12 +31,8 @@ public class EnchantmentManager {
|
||||||
}
|
}
|
||||||
Enchantment.registerEnchantment(en);
|
Enchantment.registerEnchantment(en);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
registered = false;
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (registered) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.night.nullvalkyrie.Events;
|
package com.night.nullvalkyrie.Events;
|
||||||
|
|
||||||
|
import com.night.nullvalkyrie.Items.Rarity;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -15,7 +16,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.night.nullvalkyrie.Items.CustomItem.loadConfig;
|
import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig;
|
||||||
|
|
||||||
public class CustomItemEvents implements Listener {
|
public class CustomItemEvents implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -25,7 +26,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Player pl = (Player) sb.getShooter();
|
Player pl = (Player) sb.getShooter();
|
||||||
if (pl.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (pl.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = pl.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = pl.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "SnowGun")) {
|
if (name.equalsIgnoreCase(Rarity.ULTRA.getColor() + "Snow Gun")) {
|
||||||
e.setDamage(10000);
|
e.setDamage(10000);
|
||||||
} else if (name.equalsIgnoreCase("AA-12")) {
|
} else if (name.equalsIgnoreCase("AA-12")) {
|
||||||
e.setDamage(7);
|
e.setDamage(7);
|
||||||
|
@ -37,7 +38,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Player player = (Player) e.getDamager();
|
Player player = (Player) e.getDamager();
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if(name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Fabled Widow Sword")) {
|
if(name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Fabled Widow Sword")) {
|
||||||
if (e.getEntity() instanceof Zombie) {
|
if (e.getEntity() instanceof Zombie) {
|
||||||
int zombie = loadConfig("ItemData\\WidowSword.yml").getInt("zombie");
|
int zombie = loadConfig("ItemData\\WidowSword.yml").getInt("zombie");
|
||||||
e.setDamage(e.getDamage() * (1 + zombie / 100));
|
e.setDamage(e.getDamage() * (1 + zombie / 100));
|
||||||
|
@ -58,7 +59,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(ChatColor.WHITE + "Grappling Hook")) {
|
if (name.equalsIgnoreCase(Rarity.RARE.getColor() + "Grappling Hook")) {
|
||||||
if(e.getState().equals(PlayerFishEvent.State.REEL_IN)) {
|
if(e.getState().equals(PlayerFishEvent.State.REEL_IN)) {
|
||||||
Location change = e.getHook().getLocation().subtract(player.getLocation());
|
Location change = e.getHook().getLocation().subtract(player.getLocation());
|
||||||
player.setVelocity(change.toVector().multiply(0.4));
|
player.setVelocity(change.toVector().multiply(0.4));
|
||||||
|
@ -72,7 +73,7 @@ public class CustomItemEvents implements Listener {
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||||
if (name.equalsIgnoreCase(ChatColor.DARK_PURPLE + "Aspect of The Void")) {
|
if (name.equalsIgnoreCase(Rarity.GRAND.getColor() + "Teleport Door")) {
|
||||||
Block block = player.getTargetBlock((Set<Material>) null, 12);
|
Block block = player.getTargetBlock((Set<Material>) null, 12);
|
||||||
Location l = block.getLocation();
|
Location l = block.getLocation();
|
||||||
l.add(0, 1, 0);
|
l.add(0, 1, 0);
|
||||||
|
@ -82,10 +83,10 @@ public class CustomItemEvents implements Listener {
|
||||||
l.setPitch(pitch);
|
l.setPitch(pitch);
|
||||||
player.teleport(l);
|
player.teleport(l);
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 10, 10);
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 10, 10);
|
||||||
} else if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "SnowGun")) {
|
} else if (name.equalsIgnoreCase(Rarity.ULTRA.getColor() + "Snow Gun")) {
|
||||||
Snowball s = player.launchProjectile(Snowball.class, player.getLocation().getDirection());
|
Snowball s = player.launchProjectile(Snowball.class, player.getLocation().getDirection());
|
||||||
s.setVelocity(player.getLocation().getDirection().multiply(10));
|
s.setVelocity(player.getLocation().getDirection().multiply(10));
|
||||||
} else if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Terminator")) {
|
} else if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
|
||||||
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
||||||
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
||||||
arrow.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
|
arrow.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
|
||||||
|
@ -99,7 +100,7 @@ public class CustomItemEvents implements Listener {
|
||||||
a2.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
|
a2.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
|
||||||
a2.setDamage(50);
|
a2.setDamage(50);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if(name.equalsIgnoreCase(ChatColor.GOLD + "Explosive Bow")) {
|
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
||||||
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
||||||
arrow.setDamage(50);
|
arrow.setDamage(50);
|
||||||
|
@ -116,9 +117,9 @@ public class CustomItemEvents implements Listener {
|
||||||
Player player = (Player) e.getEntity();
|
Player player = (Player) e.getEntity();
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Terminator")) {
|
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if(name.equalsIgnoreCase(ChatColor.GOLD + "Explosive Bow")) {
|
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Player shooter = (Player) e.getEntity().getShooter();
|
Player shooter = (Player) e.getEntity().getShooter();
|
||||||
if(shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if(shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if(name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade")) {
|
if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
||||||
if(e.getHitBlock() == null) {
|
if(e.getHitBlock() == null) {
|
||||||
Location l = e.getHitEntity().getLocation();
|
Location l = e.getHitEntity().getLocation();
|
||||||
e.getHitEntity().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
|
e.getHitEntity().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
|
||||||
|
@ -139,7 +140,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Location l = e.getHitBlock().getLocation();
|
Location l = e.getHitBlock().getLocation();
|
||||||
e.getHitBlock().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
|
e.getHitBlock().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
|
||||||
}
|
}
|
||||||
} else if(name.equalsIgnoreCase(ChatColor.GOLD + "Explosive Bow")) {
|
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
Arrow arrow = (Arrow) e.getEntity();
|
Arrow arrow = (Arrow) e.getEntity();
|
||||||
Location al = arrow.getLocation();
|
Location al = arrow.getLocation();
|
||||||
shooter.getWorld().createExplosion(al, 100, false, false);
|
shooter.getWorld().createExplosion(al, 100, false, false);
|
||||||
|
@ -160,7 +161,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Player player = (Player) e.getEntity().getShooter();
|
Player player = (Player) e.getEntity().getShooter();
|
||||||
if(player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if(player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade")) {
|
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
||||||
Egg s = (Egg) e.getEntity();
|
Egg s = (Egg) e.getEntity();
|
||||||
s.setVelocity(player.getLocation().getDirection().multiply(10));
|
s.setVelocity(player.getLocation().getDirection().multiply(10));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,260 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +1,81 @@
|
||||||
package com.night.nullvalkyrie.Items;
|
package com.night.nullvalkyrie.Items;
|
||||||
|
|
||||||
|
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.FileConfiguration;
|
||||||
|
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.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class CustomItemManager {
|
public class CustomItemManager {
|
||||||
public ItemStack register(Material item, String name, Rarity rarity, HashMap<String, List<String>> lore, HashMap<Enchantment, Integer> enchantment, double damage, double movespeed) {
|
private static HashMap<String, ItemStack> a = new HashMap<>();
|
||||||
ItemStack i = new ItemStack(item);
|
private static Main main;
|
||||||
for(Enchantment e : enchantment.keySet()) {
|
public CustomItemManager(Main main) {
|
||||||
i.addUnsafeEnchantment(e, enchantment.get(e));
|
this.main = main;
|
||||||
|
if(!main.getDataFolder().exists()) {
|
||||||
|
main.getDataFolder().mkdir();
|
||||||
}
|
}
|
||||||
|
createItemDataDirectory("ItemData");
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
public void register() {
|
||||||
|
List<String> hh = getAllFilesFromDirectory("ItemData");
|
||||||
|
for(int kk = 0; kk < hh.size(); kk++) {
|
||||||
|
FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk));
|
||||||
|
ItemStack i = new ItemStack(Material.matchMaterial(c.getString("material")));
|
||||||
|
HashMap<String, List<String>> d = new HashMap<>();
|
||||||
|
List<String> pr = new ArrayList<>();
|
||||||
|
List<String> ia = new ArrayList<>();
|
||||||
|
HashMap<String, Double> aa = new HashMap<>();
|
||||||
|
for (String key : c.getKeys(true)) {
|
||||||
|
if (key.startsWith("enchants.")) {
|
||||||
|
i.addUnsafeEnchantment(Enchantment.getByKey(NamespacedKey.minecraft(Arrays.asList(key.split("\\.")).get(1))), c.getInt(key));
|
||||||
|
} else if (key.startsWith("lore.properties.")) {
|
||||||
|
String property = Arrays.asList(key.split("\\.")).get(2);
|
||||||
|
if (property.equals("damage") && c.getInt(key) > 0) {
|
||||||
|
pr.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+" + c.getInt(key));
|
||||||
|
} else if (property.equals("damage") && c.getInt(key) > 0) {
|
||||||
|
pr.add(ChatColor.GRAY + "Speed: " + ChatColor.RED + "+" + c.getInt(key));
|
||||||
|
}
|
||||||
|
} else if (key.startsWith("lore.ability.")) {
|
||||||
|
String a = Arrays.asList(key.split("\\.")).get(2);
|
||||||
|
if (a.equals("name")) {
|
||||||
|
ia.add(ChatColor.GOLD + "Item Ability: " + c.getString(key));
|
||||||
|
} else if (a.equals("details")) {
|
||||||
|
for (Object line : c.getList(key)) {
|
||||||
|
ia.add(ChatColor.GRAY.toString() + line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (key.startsWith("attributes.")) {
|
||||||
|
if (c.getDouble(key) > 0.0) {
|
||||||
|
aa.put(Arrays.asList(key.split("\\.")).get(1), c.getDouble(key));
|
||||||
|
}
|
||||||
|
} else if (key.startsWith("recipe.")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d.put("properties", pr);
|
||||||
|
d.put("ability", ia);
|
||||||
|
d.put("attributes", pr);
|
||||||
ItemMeta im = i.getItemMeta();
|
ItemMeta im = i.getItemMeta();
|
||||||
im.setDisplayName(rarity.getColor() + name);
|
im.setDisplayName(Rarity.getRarity(c.getString("rarity")).getColor() + c.getString("name"));
|
||||||
im.setUnbreakable(true);
|
im.setUnbreakable(true);
|
||||||
ArrayList<String> l = new ArrayList<>();
|
ArrayList<String> l = new ArrayList<>();
|
||||||
for(String ll : lore.get("properties")) {
|
l.addAll(d.get("properties"));
|
||||||
l.add(ll);
|
|
||||||
}
|
|
||||||
l.add("");
|
l.add("");
|
||||||
ArrayList<String> e = new ArrayList<>();
|
ArrayList<String> e = new ArrayList<>();
|
||||||
for (Enchantment ee : i.getEnchantments().keySet()) {
|
for (Enchantment ee : i.getEnchantments().keySet()) {
|
||||||
|
@ -32,33 +83,99 @@ public class CustomItemManager {
|
||||||
StringBuilder n = new StringBuilder();
|
StringBuilder n = new StringBuilder();
|
||||||
for (String ii : splitted) {
|
for (String ii : splitted) {
|
||||||
String s = ii.substring(0, 1).toUpperCase() + ii.substring(1);
|
String s = ii.substring(0, 1).toUpperCase() + ii.substring(1);
|
||||||
if(splitted.size() > 1) {
|
if (splitted.size() > 1) {
|
||||||
if(ii.equals(splitted.get(splitted.size() - 1))) {
|
if (ii.equals(splitted.get(splitted.size() - 1))) {
|
||||||
n.append(s);
|
n.append(s);
|
||||||
} else {
|
} else {
|
||||||
n.append(s);
|
n.append(s);
|
||||||
n.append(" ");
|
n.append(" ");
|
||||||
}
|
}
|
||||||
} else n.append(s);
|
} else n.append(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
e.add(n + " " + i.getEnchantmentLevel(ee));
|
e.add(n + " " + i.getEnchantmentLevel(ee));
|
||||||
}
|
}
|
||||||
l.add(ChatColor.BLUE + String.join(", ", e));
|
l.add(ChatColor.BLUE + String.join(", ", e));
|
||||||
l.add("");
|
l.add("");
|
||||||
for(String ll : lore.get("ability")) {
|
l.addAll(ia);
|
||||||
l.add(ll);
|
|
||||||
}
|
|
||||||
l.add("");
|
l.add("");
|
||||||
l.add(rarity.getDisplay());
|
l.add(Rarity.getRarity(c.getString("rarity")).getDisplay());
|
||||||
im.setLore(l);
|
im.setLore(l);
|
||||||
AttributeModifier d = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", damage, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
|
for (String q : aa.keySet()) {
|
||||||
im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, d);
|
if (q.equals("damage")) {
|
||||||
AttributeModifier s = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", movespeed, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
|
AttributeModifier p = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", aa.get(q), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
|
||||||
|
im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, p);
|
||||||
|
} else if (q.equals("moveSpeed")) {
|
||||||
|
AttributeModifier s = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", aa.get(q), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
|
||||||
im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, s);
|
im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
|
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
|
||||||
i.setItemMeta(im);
|
i.setItemMeta(im);
|
||||||
|
a.put(c.getString("name"), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void setItemRecipe(NamespacedKey key, ItemStack i, int ingredient, String shape1, String shape2, String shape3, List<Material> ingredients) {
|
||||||
|
// ShapedRecipe wither_sword_recipe = new ShapedRecipe(new NamespacedKey(main, "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);
|
||||||
|
}
|
||||||
|
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 i;
|
}
|
||||||
|
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 List<String> getAllFilesFromDirectory(String path) {
|
||||||
|
ArrayList<String> ns = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
File f = new File(main.getDataFolder(), path);
|
||||||
|
File[] files = f.listFiles();
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
ns.add(files[i].getName());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return ns;
|
||||||
|
}
|
||||||
|
public static ItemStack getItem(String name){
|
||||||
|
return a.get(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ public enum Rarity {
|
||||||
EPIC(net.md_5.bungee.api.ChatColor.of("#b201b2").toString() + ChatColor.BOLD + "EPIC", net.md_5.bungee.api.ChatColor.of("#b201b2").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()),
|
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()),
|
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()),
|
ULTRA(ChatColor.RED.toString() + ChatColor.BOLD + "ULTRA", ChatColor.RED.toString()),
|
||||||
GRAND(net.md_5.bungee.api.ChatColor.of("#ffc509").toString() + ChatColor.BOLD + "GRAND", net.md_5.bungee.api.ChatColor.of("#ffc509").toString());
|
GRAND(net.md_5.bungee.api.ChatColor.of("#00fdff").toString() + ChatColor.BOLD + "GRAND", net.md_5.bungee.api.ChatColor.of("#00fdff").toString());
|
||||||
private String display;
|
private String display;
|
||||||
private String color;
|
private String color;
|
||||||
Rarity(String display, String color) {
|
Rarity(String display, String color) {
|
||||||
|
@ -22,4 +22,26 @@ public enum Rarity {
|
||||||
public String getColor() {
|
public String getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
public static Rarity getRarity(String str) {
|
||||||
|
switch(str) {
|
||||||
|
case "COMMON":
|
||||||
|
return COMMON;
|
||||||
|
case "UNCOMMON":
|
||||||
|
return UNCOMMON;
|
||||||
|
case "RARE":
|
||||||
|
return RARE;
|
||||||
|
case "EPIC":
|
||||||
|
return EPIC;
|
||||||
|
case "LEGENDARY":
|
||||||
|
return LEGENDARY;
|
||||||
|
case "MYTHIC":
|
||||||
|
return MYTHIC;
|
||||||
|
case "ULTRA":
|
||||||
|
return ULTRA;
|
||||||
|
case "GRAND":
|
||||||
|
return GRAND;
|
||||||
|
default:
|
||||||
|
return COMMON;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.night.nullvalkyrie;
|
||||||
import com.night.nullvalkyrie.Chests.MenuListener;
|
import com.night.nullvalkyrie.Chests.MenuListener;
|
||||||
import com.night.nullvalkyrie.Enchantments.EnchantmentManager;
|
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;
|
||||||
|
@ -29,7 +28,6 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
private SideBarManager sideBarManager;
|
private SideBarManager sideBarManager;
|
||||||
private BelowNameManager belowNameManager;
|
private BelowNameManager belowNameManager;
|
||||||
private CustomItemManager customItemManager;
|
private CustomItemManager customItemManager;
|
||||||
private CustomItem customItems;
|
|
||||||
|
|
||||||
public RankManager getRankManager() {
|
public RankManager getRankManager() {
|
||||||
return rankManager;
|
return rankManager;
|
||||||
|
@ -50,6 +48,7 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
return customItemManager;
|
return customItemManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
new VanishCommand();
|
new VanishCommand();
|
||||||
|
@ -57,13 +56,13 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
new AnvilCommand();
|
new AnvilCommand();
|
||||||
new ArmorCommand();
|
new ArmorCommand();
|
||||||
new MenuCommand();
|
new MenuCommand();
|
||||||
new RankCommand(this);
|
|
||||||
new MessageCommand();
|
new MessageCommand();
|
||||||
new HologramCommand();
|
new HologramCommand();
|
||||||
new CraftCommand();
|
new CraftCommand();
|
||||||
new EnchantingCommand();
|
new EnchantingCommand();
|
||||||
new SpawnCommand();
|
new SpawnCommand();
|
||||||
new WeaponCommand();
|
new RankCommand(this);
|
||||||
|
new WeaponCommand(this);
|
||||||
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);
|
||||||
|
@ -73,20 +72,15 @@ 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();
|
||||||
customItemManager = new CustomItemManager();
|
new EnchantmentManager();
|
||||||
customItems = new CustomItem(this);
|
customItemManager = new CustomItemManager(this);
|
||||||
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().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());
|
||||||
e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -22,8 +22,10 @@ public class ScoreboardListener implements Listener {
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if(!player.hasPlayedBefore()) {
|
if(!player.hasPlayedBefore()) {
|
||||||
|
e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20);
|
||||||
main.getRankManager().setRank(player.getUniqueId(), Rank.ROOKIE);
|
main.getRankManager().setRank(player.getUniqueId(), Rank.ROOKIE);
|
||||||
}
|
}
|
||||||
|
e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1");
|
||||||
main.getNameTagManager().setNametags(player);
|
main.getNameTagManager().setNametags(player);
|
||||||
main.getNameTagManager().newTag(player);
|
main.getNameTagManager().newTag(player);
|
||||||
main.getSideBarManager().setSideBar(player);
|
main.getSideBarManager().setSideBar(player);
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
package com.night.nullvalkyrie.commands;
|
package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import com.night.nullvalkyrie.Items.CustomItem;
|
import com.night.nullvalkyrie.Items.CustomItemManager;
|
||||||
|
import com.night.nullvalkyrie.Main;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class WeaponCommand extends Command {
|
public class WeaponCommand extends Command {
|
||||||
|
private Main main;
|
||||||
public WeaponCommand() {
|
public WeaponCommand(Main main) {
|
||||||
super(
|
super(
|
||||||
"weapon",
|
"weapon",
|
||||||
new String[]{},
|
new String[]{},
|
||||||
|
@ -19,36 +23,36 @@ public class WeaponCommand extends Command {
|
||||||
""
|
""
|
||||||
|
|
||||||
);
|
);
|
||||||
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
List<String> arg = Arrays.asList(args);
|
|
||||||
//arg.remove(0); //in case buggy bukkit make it bug again
|
|
||||||
String name = String.join(" ", arg);
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if(name.equalsIgnoreCase("Snow Gun")) {
|
StringBuilder s = new StringBuilder();
|
||||||
player.getInventory().addItem(CustomItem.SnowGun);
|
List<String> b = Arrays.asList(args);
|
||||||
} else if(name.equalsIgnoreCase("Grenade")) {
|
for(String a: args) {
|
||||||
player.getInventory().addItem(CustomItem.Grenade);
|
if(a.equals(b.get(b.size() - 1))) {
|
||||||
} else if(name.equalsIgnoreCase("Widow Sword")) {
|
s.append(a);
|
||||||
player.getInventory().addItem(CustomItem.WidowSword);
|
} else {
|
||||||
} else if(name.equalsIgnoreCase("Terminator")) {
|
s.append(a);
|
||||||
player.getInventory().addItem(CustomItem.Terminator);
|
s.append(" ");
|
||||||
} else if(name.equalsIgnoreCase("Explosive Bow")) {
|
}
|
||||||
player.getInventory().addItem(CustomItem.ExplosiveBow);
|
|
||||||
} else if(name.equalsIgnoreCase("AOTV")) {
|
}
|
||||||
player.getInventory().addItem(CustomItem.AOTV);
|
ItemStack item = main.getCustomItemManager().getItem(s.toString());
|
||||||
} else if(name.equalsIgnoreCase("Grappling Hook")) {
|
if(item.hasItemMeta()) {
|
||||||
player.getInventory().addItem(CustomItem.GrapplingHook);
|
player.getInventory().addItem(item);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + "This item doesn't exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
return StringUtil.copyPartialMatches(args[0], Arrays.asList("Snow Gun", "Grenade", "Widow Sword", "Terminator", "Explosive Bow", "AOTV", "Grappling Hook"), new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[0], Arrays.asList("Snow Gun", "Frag Grenade", "Widow Sword", "Terminator", "Explosive Bow", "Teleport Door", "Grappling Hook"), new ArrayList<>());
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue