From e4ed6dad0c9c3dab729c6764a9c2836637862633 Mon Sep 17 00:00:00 2001 From: A5005 <44929101+A5005@users.noreply.github.com> Date: Mon, 8 Nov 2021 11:58:41 +0100 Subject: [PATCH] Workspace Upload --- BindItems.java | 151 +++++ Calculator.java | 55 ++ Collection.java | 1310 ++++++++++++++++++------------------ CollectionNew.java | 645 ++++++++++++++++++ ItemData.java | 22 + Level.java | 99 +++ PlayerList.java | 57 ++ commands/Broadcast.java | 54 ++ commands/Bypass.java | 127 ++++ commands/Claim.java | 114 ++++ commands/ClearChat.java | 30 + commands/EnumTest.java | 5 + commands/Force.java | 27 + commands/ThrowingAxe.java | 33 + extras/CreateGlow.java | 30 + extras/Glow.java | 74 ++ extras/MySQL.java | 108 +++ extras/TestDatabase.java | 20 + main/Main.java | 71 ++ program/Boot.java | 24 + program/Zufallszahl.java | 18 + weapons/Launcher.java | 26 + weapons/Rifle.java | 23 + weapons/Test.java | 23 + weapons/Weapon.java | 65 ++ weapons/WeaponHandler.java | 90 +++ 26 files changed, 2646 insertions(+), 655 deletions(-) create mode 100644 BindItems.java create mode 100644 Calculator.java create mode 100644 CollectionNew.java create mode 100644 ItemData.java create mode 100644 Level.java create mode 100644 PlayerList.java create mode 100644 commands/Broadcast.java create mode 100644 commands/Bypass.java create mode 100644 commands/Claim.java create mode 100644 commands/ClearChat.java create mode 100644 commands/EnumTest.java create mode 100644 commands/Force.java create mode 100644 commands/ThrowingAxe.java create mode 100644 extras/CreateGlow.java create mode 100644 extras/Glow.java create mode 100644 extras/MySQL.java create mode 100644 extras/TestDatabase.java create mode 100644 main/Main.java create mode 100644 program/Boot.java create mode 100644 program/Zufallszahl.java create mode 100644 weapons/Launcher.java create mode 100644 weapons/Rifle.java create mode 100644 weapons/Test.java create mode 100644 weapons/Weapon.java create mode 100644 weapons/WeaponHandler.java diff --git a/BindItems.java b/BindItems.java new file mode 100644 index 0000000..85347f6 --- /dev/null +++ b/BindItems.java @@ -0,0 +1,151 @@ +package de.luke.naruto; + +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import de.luke.naruto.commands.Bypass; +import de.luke.naruto.extras.TestDatabase; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class BindItems implements Listener { + + @EventHandler + public void onPlayerFirstJoin(PlayerJoinEvent event) throws SQLException { + Player p = event.getPlayer(); + + if (!p.hasPlayedBefore()) { + ItemStack arrow = new ItemStack(Material.ARROW); + ItemMeta arrowim = arrow.getItemMeta(); + arrowim.setDisplayName("§f§lKunai"); + arrow.setItemMeta(arrowim); + + p.getInventory().setItem(8, new ItemStack(arrow)); + + p.updateInventory(); + + ItemStack chest = new ItemStack(Material.ENDER_CHEST); + ItemMeta chestim = chest.getItemMeta(); + chestim.setDisplayName("§c§lCollection"); + chest.setItemMeta(chestim); + p.getInventory().setItem(17, new ItemStack(chest)); + + p.updateInventory(); + Bukkit.broadcastMessage("§bWelcome §a" + p.getName() + " §bto the Server!"); + + PreparedStatement st = null; + + st = TestDatabase.mysql.getConnection().prepareStatement( + "INSERT INTO `Materialnumber`(`uuid`,`sticknumber`,`woodbuttonnumber`,`stonebuttonnumber`,`woodpreasureplatenumber`,`stonepreasureplatenumber`,`feathernumber`,`leathernumber`,`papernumber`,`booknumber`,`stringnumber`,`bonenumber`,`bricknumber`,`netherbricknumber`,`claynumber`,`coalnumber`,`flintnumber`,`gunpowdernumber`,`fireworkstarnumber`,`spidereggnumber`,`glowstonenumber`,`quartznumber`,`magmacreamnumber`,`ironnumber`,`goldnumber`,`prismarineshardnumber`,`prismarinecrystalnumber`,`compassnumber`,`ghasttearnumber`,`blazepowdernumber`,`slimeballnumber`,`eyeofendernumber`,`diamondnumber`,`emeraldnumber`,`bottleofenchantingnumber`,`netherstarnumber`,`endcrystalnumber`) VALUES (\"" + + p.getUniqueId().toString() + + "\",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)"); + st.execute(); + + st = TestDatabase.mysql.getConnection() + .prepareStatement("INSERT INTO `Arrow`(`uuid`, `number`, `hasblueprint`, `level`) VALUES (\"" + + p.getUniqueId() + "\",0,true,1)"); + st.execute(); + } + + } + + @EventHandler + public void onRespawn(PlayerRespawnEvent event) { + Player p = event.getPlayer(); + ItemStack arrow = new ItemStack(Material.ARROW); + ItemMeta arrowim = arrow.getItemMeta(); + arrowim.setDisplayName("§f§lKunai"); + arrow.setItemMeta(arrowim); + + p.getInventory().setItem(8, new ItemStack(arrow)); + + p.updateInventory(); + + ItemStack chest = new ItemStack(Material.ENDER_CHEST); + ItemMeta chestim = chest.getItemMeta(); + chestim.setDisplayName("§c§lCollection"); + chest.setItemMeta(chestim); + p.getInventory().setItem(17, new ItemStack(chest)); + + p.updateInventory(); + + } + + @EventHandler + public void onDrop(PlayerDropItemEvent event) throws SQLException { + Player player = event.getPlayer(); + if (Bypass.isBypassed(player.getUniqueId().toString()) == false) { + event.setCancelled(true); + } + + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) throws SQLException { + + if (event.getWhoClicked() instanceof Player) { + if (event.getClickedInventory() == null) + return; + if ((event.getCurrentItem().getType() == Material.ENDER_CHEST)) { + Collection.openGUIcommonMaterials((Player) event.getWhoClicked()); + event.setCancelled(true); + return; + } + + if ((event.getWhoClicked().getOpenInventory().getTopInventory().getName().toString().contains("Material")) + || (event.getWhoClicked().getOpenInventory().getTopInventory().getName().toString() + .contains("Weapons"))) { + + event.setCancelled(true); + } + + } else + event.setCancelled(true); + + } + + @EventHandler + public void onSetAttempt(PlayerInteractEvent event) throws SQLException { + // check if the action is left click or an attempt to break a block AND the + // block is bedrock + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { + Player player = event.getPlayer(); + if (Bypass.isBypassed(player.getUniqueId().toString()) == false) { + event.setCancelled(true); + } + } + } + + @EventHandler + public void onBreakAttempt(PlayerInteractEvent event) throws SQLException { + // check if the action is left click or an attempt to break a block AND the + // block is bedrock + if (event.getAction() == Action.LEFT_CLICK_BLOCK) { + Player player = event.getPlayer(); + if (Bypass.isBypassed(player.getUniqueId().toString()) == false) { + event.setCancelled(true); + } + } + } + + // Hunger loss + @EventHandler + public void onFoodLevelChange(FoodLevelChangeEvent event) { + event.setCancelled(true); + } + +} diff --git a/Calculator.java b/Calculator.java new file mode 100644 index 0000000..7ec1ff6 --- /dev/null +++ b/Calculator.java @@ -0,0 +1,55 @@ +package de.luke.naruto; + +import java.io.File; + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +public class Calculator implements CommandExecutor { + + //Level 1 = 0xp + //Level 2 = 200xp + //Level 3 = 200xp+(3*100) + //Level 4 = 500xp+(400) + //Level 5 = 900xp +(500) + + + + public static int level(int xp) { + int x = 200; + int Durchläufe = 0; + while (!(x > xp)) { + x = x + (Durchläufe + 3) * 100; + Durchläufe++; + } + + + + + return (Durchläufe + 1); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + String playerName = player.getName(); + File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase"); + File f = new File(userdata, File.separator + playerName + ".yml"); + FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); + sender.sendMessage("§a§lLevel: "+ level(playerData.getInt("xplevel.balance"))); + + + + + } else sender.sendMessage("§cCommand only for Players!"); + + + return false; + } +} diff --git a/Collection.java b/Collection.java index 6a1b80d..a9f20b5 100644 --- a/Collection.java +++ b/Collection.java @@ -1,655 +1,655 @@ -package de.luke.naruto; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.material.MaterialData; - -import de.luke.naruto.extras.Glow; -import de.luke.naruto.extras.TestDatabase; - -public class Collection implements Listener { - - static ItemStack commonMaterialGlow; - static ItemStack commonMaterial; - static ItemStack uncommonMaterial; - static ItemStack uncommonMaterialGlow; - static ItemStack rareMaterial; - static ItemStack rareMaterialGlow; - static ItemStack epicMaterial; - static ItemStack epicMaterialGlow; - static ItemStack commonWeapons; - static ItemStack commonWeaponsGlow; - static ItemStack uncommonWeapons; - static ItemStack uncommonWeaponsGlow; - static ItemStack rareWeapons; - static ItemStack rareWeaponsGlow; - static ItemStack legendaryWeapons; - static ItemStack legendaryWeaponsGlow; - static ItemStack exclusiveWeapons; - static ItemStack exclusiveWeaponsGlow; - static ItemStack glas; - - static ItemStack Stick; - static ItemMeta Stickim; - - static ItemStack Woodbutton; - static ItemMeta Woodbuttonim; - - static ItemStack Stonebutton; - static ItemMeta Stonebuttonim; - - static ItemStack Woodpreasureplate; - static ItemMeta Woodpreasureplateim; - - static ItemStack Stonepreasureplate; - static ItemMeta Stonepreasureplateim; - - static ItemStack Feather; - static ItemMeta Featherim; - - static ItemStack Leather; - static ItemMeta Leatherim; - - static ItemStack Paper; - static ItemMeta Paperim; - - static ItemStack Book; - static ItemMeta Bookim; - - static List arrowlore = new ArrayList<>(); - - static ItemStack Arrow; - static ItemMeta Arrowim; - - static ItemStack Arrowamount; - static ItemMeta Arrowamountim; - - static List workbenchlore = new ArrayList<>(); - - static ItemStack Workbench; - static ItemMeta Workbenchim; - - static ItemStack Wool; - static ItemMeta Woolim; - - @SuppressWarnings("deprecation") - public static void Build() { - - Workbench = new MaterialData(Material.WORKBENCH, (byte) 0).toItemStack(1); - Workbenchim = Workbench.getItemMeta(); - Workbenchim.setDisplayName("§f§lCraft"); - - Wool = new MaterialData(Material.WOOL, (byte) 5).toItemStack(1); - Woolim = Wool.getItemMeta(); - Woolim.setDisplayName("§a§lClaim"); - Wool.setItemMeta(Woolim); - - Stick = new MaterialData(Material.STICK, (byte) 0).toItemStack(1); - Stickim = Stick.getItemMeta(); - Stickim.setDisplayName("§f§lStick"); - - Woodbutton = new MaterialData(Material.WOOD_BUTTON, (byte) 0).toItemStack(1); - Woodbuttonim = Woodbutton.getItemMeta(); - Woodbuttonim.setDisplayName("§f§lWooden Button"); - - Stonebutton = new MaterialData(Material.STONE_BUTTON, (byte) 0).toItemStack(1); - Stonebuttonim = Stonebutton.getItemMeta(); - Stonebuttonim.setDisplayName("§f§lStone Button"); - - Woodpreasureplate = new MaterialData(Material.WOOD_PLATE, (byte) 0).toItemStack(1); - Woodpreasureplateim = Woodpreasureplate.getItemMeta(); - Woodpreasureplateim.setDisplayName("§f§lWooden Pressure Plate"); - - Stonepreasureplate = new MaterialData(Material.STONE_PLATE, (byte) 0).toItemStack(1); - Stonepreasureplateim = Stonepreasureplate.getItemMeta(); - Stonepreasureplateim.setDisplayName("§f§lStone Pressure Plate"); - - Feather = new MaterialData(Material.FEATHER, (byte) 0).toItemStack(1); - Featherim = Feather.getItemMeta(); - Featherim.setDisplayName("§f§lFeather"); - - Leather = new MaterialData(Material.LEATHER, (byte) 0).toItemStack(1); - Leatherim = Leather.getItemMeta(); - Leatherim.setDisplayName("§f§lLeather"); - - Paper = new MaterialData(Material.PAPER, (byte) 0).toItemStack(1); - Paperim = Paper.getItemMeta(); - Paperim.setDisplayName("§f§lPaper"); - - Book = new MaterialData(Material.BOOK, (byte) 0).toItemStack(1); - Bookim = Book.getItemMeta(); - Bookim.setDisplayName("§f§lBook"); - - arrowlore.add("§7Click to open the menu!"); - - Arrow = new MaterialData(Material.ARROW, (byte) 0).toItemStack(1); - Arrowim = Arrow.getItemMeta(); - Arrowim.setDisplayName("§f§lThrowing Knife"); - Arrowim.setLore(arrowlore); - Arrow.setItemMeta(Arrowim); - - Glow glow = new Glow(120); // 120 for custom enchant glow - - System.out.println("ItemStacks Builded!"); - commonMaterial = new MaterialData(Material.INK_SACK, (byte) 8).toItemStack(1); - ItemMeta commonMaterialim = commonMaterial.getItemMeta(); - commonMaterialim.setDisplayName("§7§lCommon Materials"); - commonMaterial.setItemMeta(commonMaterialim); - - commonMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 8).toItemStack(1); - ItemMeta commonMaterialGlowim = commonMaterialGlow.getItemMeta(); - commonMaterialGlowim.setDisplayName("§7§lCommon Materials"); - commonMaterialGlowim.addEnchant(glow, 1, true); - commonMaterialGlow.setItemMeta(commonMaterialGlowim); - - uncommonMaterial = new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1); - ItemMeta uncommonMaterialim = uncommonMaterial.getItemMeta(); - uncommonMaterialim.setDisplayName("§a§lUncommon Materials"); - uncommonMaterial.setItemMeta(uncommonMaterialim); - - uncommonMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1); - ItemMeta uncommonMaterialGlowim = uncommonMaterialGlow.getItemMeta(); - uncommonMaterialGlowim.addEnchant(glow, 1, true); - uncommonMaterialGlowim.setDisplayName("§a§lUncommon Materials"); - uncommonMaterialGlow.setItemMeta(uncommonMaterialGlowim); - - rareMaterial = new MaterialData(Material.INK_SACK, (byte) 12).toItemStack(1); - ItemMeta rareMaterialim = rareMaterial.getItemMeta(); - rareMaterialim.setDisplayName("§3§lRare Materials"); - rareMaterial.setItemMeta(rareMaterialim); - - rareMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 12).toItemStack(1); - ItemMeta rareMaterialGlowim = rareMaterialGlow.getItemMeta(); - rareMaterialGlowim.addEnchant(glow, 1, true); - rareMaterialGlowim.setDisplayName("§3§lRare Materials"); - rareMaterialGlow.setItemMeta(rareMaterialGlowim); - - epicMaterial = new MaterialData(Material.INK_SACK, (byte) 5).toItemStack(1); - ItemMeta epicMaterialim = epicMaterial.getItemMeta(); - epicMaterialim.setDisplayName("§5§lEpic Materials"); - epicMaterial.setItemMeta(epicMaterialim); - - epicMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 5).toItemStack(1); - ItemMeta epicMaterialGlowim = epicMaterialGlow.getItemMeta(); - epicMaterialGlowim.addEnchant(glow, 1, true); - epicMaterialGlowim.setDisplayName("§5§lEpic Materials"); - epicMaterialGlow.setItemMeta(epicMaterialGlowim); - - commonWeapons = new MaterialData(Material.INK_SACK, (byte) 15).toItemStack(1); - ItemMeta commonWeaponsim = commonWeapons.getItemMeta(); - commonWeaponsim.setDisplayName("§f§lCommon Weapons"); - commonWeapons.setItemMeta(commonWeaponsim); - - commonWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 15).toItemStack(1); - ItemMeta commonWeaponsGlowim = commonWeaponsGlow.getItemMeta(); - commonWeaponsGlowim.addEnchant(glow, 1, true); - commonWeaponsGlowim.setDisplayName("§f§lCommon Weapons"); - commonWeaponsGlow.setItemMeta(commonWeaponsGlowim); - - uncommonWeapons = new MaterialData(Material.INK_SACK, (byte) 2).toItemStack(1); - ItemMeta uncommonWeaponsim = uncommonWeapons.getItemMeta(); - uncommonWeaponsim.setDisplayName("§2§lUncommon Weapons"); - uncommonWeapons.setItemMeta(uncommonWeaponsim); - - uncommonWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 2).toItemStack(1); - ItemMeta uncommonWeaponsGlowim = uncommonWeaponsGlow.getItemMeta(); - uncommonWeaponsGlowim.addEnchant(glow, 1, true); - uncommonWeaponsGlowim.setDisplayName("§2§lUncommon Weapons"); - uncommonWeaponsGlow.setItemMeta(uncommonWeaponsGlowim); - - rareWeapons = new MaterialData(Material.INK_SACK, (byte) 4).toItemStack(1); - ItemMeta rareWeaponsim = rareWeapons.getItemMeta(); - rareWeaponsim.setDisplayName("§1§lRare Weapons"); - rareWeapons.setItemMeta(rareWeaponsim); - - rareWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 4).toItemStack(1); - ItemMeta rareWeaponsGlowim = rareWeaponsGlow.getItemMeta(); - rareWeaponsGlowim.addEnchant(glow, 1, true); - rareWeaponsGlowim.setDisplayName("§1§lRare Weapons"); - rareWeaponsGlow.setItemMeta(rareWeaponsGlowim); - - legendaryWeapons = new MaterialData(Material.INK_SACK, (byte) 11).toItemStack(1); - ItemMeta legendaryWeaponsim = legendaryWeapons.getItemMeta(); - legendaryWeaponsim.setDisplayName("§e§lLegendary Weapons"); - legendaryWeapons.setItemMeta(legendaryWeaponsim); - - legendaryWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 11).toItemStack(1); - ItemMeta legendaryWeaponsGlowim = legendaryWeaponsGlow.getItemMeta(); - legendaryWeaponsGlowim.addEnchant(glow, 1, true); - legendaryWeaponsGlowim.setDisplayName("§e§lLegendary Weapons"); - legendaryWeaponsGlow.setItemMeta(legendaryWeaponsGlowim); - - exclusiveWeapons = new MaterialData(Material.INK_SACK, (byte) 1).toItemStack(1); - ItemMeta exclusiveWeaponsim = exclusiveWeapons.getItemMeta(); - exclusiveWeaponsim.setDisplayName("§4§lExclusive Weapons"); - exclusiveWeapons.setItemMeta(exclusiveWeaponsim); - - exclusiveWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 1).toItemStack(1); - ItemMeta exclusiveWeaponsGlowim = exclusiveWeaponsGlow.getItemMeta(); - exclusiveWeaponsGlowim.addEnchant(glow, 1, true); - exclusiveWeaponsGlowim.setDisplayName("§4§lExclusive Weapons"); - exclusiveWeaponsGlow.setItemMeta(exclusiveWeaponsGlowim); - - glas = new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15).toItemStack(1); - ItemMeta glasim = glas.getItemMeta(); - glasim.setDisplayName(" "); - glas.setItemMeta(glasim); - - } - - private static void defaultinventory(Inventory inventory) { - inventory.setItem(0, new ItemStack(commonMaterial)); - inventory.setItem(1, new ItemStack(uncommonMaterial)); - inventory.setItem(2, new ItemStack(rareMaterial)); - inventory.setItem(3, new ItemStack(epicMaterial)); - inventory.setItem(4, new ItemStack(commonWeapons)); - inventory.setItem(5, new ItemStack(uncommonWeapons)); - inventory.setItem(6, new ItemStack(rareWeapons)); - inventory.setItem(7, new ItemStack(legendaryWeapons)); - inventory.setItem(8, new ItemStack(exclusiveWeapons)); - inventory.setItem(9, new ItemStack(glas)); - inventory.setItem(10, new ItemStack(glas)); - inventory.setItem(11, new ItemStack(glas)); - inventory.setItem(12, new ItemStack(glas)); - inventory.setItem(13, new ItemStack(glas)); - inventory.setItem(14, new ItemStack(glas)); - inventory.setItem(15, new ItemStack(glas)); - inventory.setItem(16, new ItemStack(glas)); - inventory.setItem(17, new ItemStack(glas)); - inventory.setItem(27, new ItemStack(glas)); - inventory.setItem(28, new ItemStack(glas)); - inventory.setItem(29, new ItemStack(glas)); - inventory.setItem(30, new ItemStack(glas)); - inventory.setItem(31, new ItemStack(glas)); - inventory.setItem(32, new ItemStack(glas)); - inventory.setItem(33, new ItemStack(glas)); - inventory.setItem(34, new ItemStack(glas)); - inventory.setItem(35, new ItemStack(glas)); - } - - public static void openGUIcommonMaterials(Player player) throws SQLException { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§7§lMaterials"); - defaultinventory(inventory); - inventory.setItem(0, new ItemStack(commonMaterialGlow)); - - PreparedStatement all = TestDatabase.mysql.getConnection().prepareStatement( - "Select `sticknumber`,`woodbuttonnumber`,`stonebuttonnumber`,`woodpreasureplatenumber`,`stonepreasureplatenumber`,`feathernumber`,`leathernumber`,`papernumber`,`booknumber` FROM `Materialnumber` WHERE `uuid` = \"" - + player.getUniqueId().toString() + "\""); - ResultSet rs = all.executeQuery(); - rs.next(); - - String StickNumber = Integer.toString(rs.getInt("sticknumber")); - String WoodbuttonNumber = Integer.toString(rs.getInt("woodbuttonnumber")); - String StonebuttonNumber = Integer.toString(rs.getInt("stonebuttonnumber")); - String WoodpreasureplateNumber = Integer.toString(rs.getInt("woodpreasureplatenumber")); - String StonepreasureplateNumber = Integer.toString(rs.getInt("stonepreasureplatenumber")); - String FeatherNumber = Integer.toString(rs.getInt("feathernumber")); - String LeatherNumber = Integer.toString(rs.getInt("leathernumber")); - String PaperNumber = Integer.toString(rs.getInt("papernumber")); - String BookNumber = Integer.toString(rs.getInt("booknumber")); - - List one = new ArrayList<>(); - one.add("§7§lYou have: §f§l" + StickNumber); - Stickim.setLore(one); - Stick.setItemMeta(Stickim); - inventory.setItem(18, new ItemStack(Stick)); - - List two = new ArrayList<>(); - two.add("§7§lYou have: §f§l" + WoodbuttonNumber); - Woodbuttonim.setLore(two); - Woodbutton.setItemMeta(Woodbuttonim); - inventory.setItem(19, new ItemStack(Woodbutton)); - - List three = new ArrayList<>(); - three.add("§7§lYou have: §f§l" + StonebuttonNumber); - Stonebuttonim.setLore(three); - Stonebutton.setItemMeta(Stonebuttonim); - inventory.setItem(20, new ItemStack(Stonebutton)); - - List four = new ArrayList<>(); - four.add("§7§lYou have: §f§l" + WoodpreasureplateNumber); - Woodpreasureplateim.setLore(four); - Woodpreasureplate.setItemMeta(Woodpreasureplateim); - inventory.setItem(21, new ItemStack(Woodpreasureplate)); - - List five = new ArrayList<>(); - five.add("§7§lYou have: §f§l" + StonepreasureplateNumber); - Stonepreasureplateim.setLore(five); - Stonepreasureplate.setItemMeta(Stonepreasureplateim); - inventory.setItem(22, new ItemStack(Stonepreasureplate)); - - List six = new ArrayList<>(); - six.add("§7§lYou have: §f§l" + FeatherNumber); - Featherim.setLore(six); - Feather.setItemMeta(Featherim); - inventory.setItem(23, new ItemStack(Feather)); - - List seven = new ArrayList<>(); - seven.add("§7§lYou have: §f§l" + LeatherNumber); - Leatherim.setLore(seven); - Leather.setItemMeta(Leatherim); - inventory.setItem(24, new ItemStack(Leather)); - - List eight = new ArrayList<>(); - eight.add("§7§lYou have: §f§l" + PaperNumber); - Paperim.setLore(eight); - Paper.setItemMeta(Paperim); - inventory.setItem(25, new ItemStack(Paper)); - - List nine = new ArrayList<>(); - nine.add("§7§lYou have: §f§l" + BookNumber); - Bookim.setLore(nine); - Book.setItemMeta(Bookim); - inventory.setItem(26, new ItemStack(Book)); - - player.openInventory(inventory); - - } - - public boolean DeadMeta(int clickedslot, String GUI_NAME) { - int Deadslot = 0; - if (GUI_NAME == "§7§lMaterials") { - Deadslot = 0; - } - if (GUI_NAME == "§a§lMaterials") { - Deadslot = 1; - } - if (GUI_NAME == "§3§lMaterials") { - Deadslot = 2; - } - if (GUI_NAME == "§5§lMaterials") { - Deadslot = 3; - } - if (GUI_NAME == "§f§lWeapons") { - Deadslot = 4; - } - if (GUI_NAME == "§2§lWeapons") { - Deadslot = 5; - } - if (GUI_NAME == "§1§lWeapons") { - Deadslot = 6; - } - if (GUI_NAME == "§e§lWeapons") { - Deadslot = 7; - } - if (GUI_NAME == "§4§lWeapons") { - Deadslot = 8; - } - - if (clickedslot == Deadslot) { - return true; - } - - return false; - - } - - @EventHandler - public void handleNavigatorGUIClickTop(InventoryClickEvent event) throws SQLException { - - if (!(event.getWhoClicked() instanceof Player)) - return; - - if (event.getClickedInventory() == null) - return; - - Player player = (Player) event.getWhoClicked(); - - if (!((event.getClickedInventory().getTitle().contains("Material") - || (event.getClickedInventory().getTitle().contains("Weapons"))))) - return; - - if (DeadMeta(event.getSlot(), event.getClickedInventory().getTitle()) == true) - return; - - if (event.getCurrentItem().getType() == Material.INK_SACK) { - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Uncommon Material")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§a§lMaterials"); - - defaultinventory(inventory); - inventory.setItem(1, new ItemStack(uncommonMaterialGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§7§lCommon Material")) { - - openGUIcommonMaterials(player); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§3§lRare Material")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§3§lMaterials"); - - defaultinventory(inventory); - inventory.setItem(2, new ItemStack(rareMaterialGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§5§lEpic Material")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§5§lMaterials"); - - defaultinventory(inventory); - inventory.setItem(3, new ItemStack(epicMaterialGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§f§lCommon Weapons")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§f§lWeapons"); - - defaultinventory(inventory); - - inventory.setItem(18, new ItemStack(Arrow)); - inventory.setItem(4, new ItemStack(commonWeaponsGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§2§lUncommon Weapons")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§2§lWeapons"); - - defaultinventory(inventory); - inventory.setItem(5, new ItemStack(uncommonWeaponsGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§1§lRare Weapons")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§1§lWeapons"); - - defaultinventory(inventory); - inventory.setItem(6, new ItemStack(rareWeaponsGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§e§lLegendary Weapons")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§e§lWeapons"); - - defaultinventory(inventory); - inventory.setItem(7, new ItemStack(legendaryWeaponsGlow)); - player.openInventory(inventory); - - return; - } - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§4§lExclusive Weapons")) { - - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§4§lWeapons"); - - defaultinventory(inventory); - inventory.setItem(8, new ItemStack(exclusiveWeaponsGlow)); - player.openInventory(inventory); - - return; - } - - } - - if (event.getCurrentItem().getItemMeta() == null) - return; - - - - if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Throwing Knife")) { - ArrowInventory(player); - return; - } - - - - - - if ((event.getCurrentItem().getItemMeta().getDisplayName().contains("Craft")) - && (event.getClickedInventory().getName().contains("Throwing Knife"))) { - ArrowCraft(player); - return; - } - - - - - if ((event.getCurrentItem().getItemMeta().getDisplayName().contains("Claim")) - && (event.getClickedInventory().getName().contains("Throwing Knife"))) - Claim(player); - - - - } - - private void Claim(Player player) throws SQLException { - int arrownumber; - PreparedStatement st; - st = TestDatabase.mysql.getConnection().prepareStatement( - "SELECT `number` FROM `Arrow` WHERE uuid = \"" + player.getUniqueId() + "\""); - - ResultSet rs = st.executeQuery(); - rs.next(); - arrownumber = rs.getInt("number"); - if (arrownumber < 1) - return; - - int arrowslot = getArrowSlot(player); - - if (arrowslot==-1) - return; - - - - player.getInventory().addItem(Arrow); - st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Arrow` SET `number` = ((Select `number` WHERE uuid =\"" + player.getUniqueId() - + "\")-1) WHERE uuid = \"" + player.getUniqueId() + "\""); - st.execute(); - ArrowInventory(player); - - } - - private void ArrowCraft(Player player) throws SQLException { - int sticknumber; - PreparedStatement st; - st = TestDatabase.mysql.getConnection().prepareStatement( - "SELECT `sticknumber` FROM `Materialnumber` WHERE uuid = \"" + player.getUniqueId() + "\""); - - ResultSet rs = st.executeQuery(); - rs.next(); - sticknumber = rs.getInt("sticknumber"); - - if (sticknumber < 2) { - return; - } - sticknumber = sticknumber - 2; - - st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Materialnumber` SET `sticknumber` = \"" - + sticknumber + "\" WHERE uuid = \"" + player.getUniqueId() + "\""); - - st.execute(); - - - - st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Arrow` SET `number` = ((Select `number` WHERE uuid =\"" + player.getUniqueId() - + "\")+1) WHERE uuid = \"" + player.getUniqueId() + "\""); - st.execute(); - - ArrowInventory(player); - } - - private void ArrowInventory(Player player) throws SQLException { - Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§f§lWeapons > Throwing Knife"); - - PreparedStatement all = TestDatabase.mysql.getConnection() - .prepareStatement("SELECT number FROM `Arrow` WHERE uuid = \"" + player.getUniqueId() + "\""); - ResultSet rs = all.executeQuery(); - rs.next(); - - PreparedStatement allmaterials = TestDatabase.mysql.getConnection().prepareStatement( - "SELECT `sticknumber` FROM `Materialnumber` WHERE uuid = \"" + player.getUniqueId() + "\""); - ResultSet rs2 = allmaterials.executeQuery(); - rs2.next(); - - int sticknumber = rs2.getInt("sticknumber"); - int arrownumber = rs.getInt("number"); - - arrowlore.removeAll(arrowlore); - arrowlore.add("§7You have: §f" + arrownumber); - Arrowim.setLore(arrowlore); - Arrow.setItemMeta(Arrowim); - - inventory.setItem(4, new ItemStack(Arrow)); - - workbenchlore.removeAll(workbenchlore); - workbenchlore.add("§72x §lStick §7(§e" + sticknumber + "§7)"); - Workbenchim.setLore(workbenchlore); - Workbench.setItemMeta(Workbenchim); - inventory.setItem(20, new ItemStack(Workbench)); - - inventory.setItem(31, new ItemStack(Wool)); - - player.openInventory(inventory); - - arrowlore.removeAll(arrowlore); - arrowlore.add("§7Click to open the menu!"); - Arrowim.setLore(arrowlore); - Arrow.setItemMeta(Arrowim); - - } - - public static int getArrowSlot(Player player) { - for (int i = 0; i < 36; i++) { - ItemStack slot = player.getInventory().getItem(i); - if (slot.getType() != Material.AIR || (slot.getType() != Material.ARROW && slot.getAmount()<64)) - return i; - } - return -1; - } -} +package de.luke.naruto; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.MaterialData; + +import de.luke.naruto.extras.Glow; +import de.luke.naruto.extras.TestDatabase; + +public class Collection implements Listener { + + static ItemStack commonMaterialGlow; + static ItemStack commonMaterial; + static ItemStack uncommonMaterial; + static ItemStack uncommonMaterialGlow; + static ItemStack rareMaterial; + static ItemStack rareMaterialGlow; + static ItemStack epicMaterial; + static ItemStack epicMaterialGlow; + static ItemStack commonWeapons; + static ItemStack commonWeaponsGlow; + static ItemStack uncommonWeapons; + static ItemStack uncommonWeaponsGlow; + static ItemStack rareWeapons; + static ItemStack rareWeaponsGlow; + static ItemStack legendaryWeapons; + static ItemStack legendaryWeaponsGlow; + static ItemStack exclusiveWeapons; + static ItemStack exclusiveWeaponsGlow; + static ItemStack glas; + + static ItemStack Stick; + static ItemMeta Stickim; + + static ItemStack Woodbutton; + static ItemMeta Woodbuttonim; + + static ItemStack Stonebutton; + static ItemMeta Stonebuttonim; + + static ItemStack Woodpreasureplate; + static ItemMeta Woodpreasureplateim; + + static ItemStack Stonepreasureplate; + static ItemMeta Stonepreasureplateim; + + static ItemStack Feather; + static ItemMeta Featherim; + + static ItemStack Leather; + static ItemMeta Leatherim; + + static ItemStack Paper; + static ItemMeta Paperim; + + static ItemStack Book; + static ItemMeta Bookim; + + static List arrowlore = new ArrayList<>(); + + static ItemStack Arrow; + static ItemMeta Arrowim; + + static ItemStack Arrowamount; + static ItemMeta Arrowamountim; + + static List workbenchlore = new ArrayList<>(); + + static ItemStack Workbench; + static ItemMeta Workbenchim; + + static ItemStack Wool; + static ItemMeta Woolim; + + @SuppressWarnings("deprecation") + public static void Build() { + + Workbench = new MaterialData(Material.WORKBENCH, (byte) 0).toItemStack(1); + Workbenchim = Workbench.getItemMeta(); + Workbenchim.setDisplayName("§f§lCraft"); + + Wool = new MaterialData(Material.WOOL, (byte) 5).toItemStack(1); + Woolim = Wool.getItemMeta(); + Woolim.setDisplayName("§a§lClaim"); + Wool.setItemMeta(Woolim); + + Stick = new MaterialData(Material.STICK, (byte) 0).toItemStack(1); + Stickim = Stick.getItemMeta(); + Stickim.setDisplayName("§f§lStick"); + + Woodbutton = new MaterialData(Material.WOOD_BUTTON, (byte) 0).toItemStack(1); + Woodbuttonim = Woodbutton.getItemMeta(); + Woodbuttonim.setDisplayName("§f§lWooden Button"); + + Stonebutton = new MaterialData(Material.STONE_BUTTON, (byte) 0).toItemStack(1); + Stonebuttonim = Stonebutton.getItemMeta(); + Stonebuttonim.setDisplayName("§f§lStone Button"); + + Woodpreasureplate = new MaterialData(Material.WOOD_PLATE, (byte) 0).toItemStack(1); + Woodpreasureplateim = Woodpreasureplate.getItemMeta(); + Woodpreasureplateim.setDisplayName("§f§lWooden Pressure Plate"); + + Stonepreasureplate = new MaterialData(Material.STONE_PLATE, (byte) 0).toItemStack(1); + Stonepreasureplateim = Stonepreasureplate.getItemMeta(); + Stonepreasureplateim.setDisplayName("§f§lStone Pressure Plate"); + + Feather = new MaterialData(Material.FEATHER, (byte) 0).toItemStack(1); + Featherim = Feather.getItemMeta(); + Featherim.setDisplayName("§f§lFeather"); + + Leather = new MaterialData(Material.LEATHER, (byte) 0).toItemStack(1); + Leatherim = Leather.getItemMeta(); + Leatherim.setDisplayName("§f§lLeather"); + + Paper = new MaterialData(Material.PAPER, (byte) 0).toItemStack(1); + Paperim = Paper.getItemMeta(); + Paperim.setDisplayName("§f§lPaper"); + + Book = new MaterialData(Material.BOOK, (byte) 0).toItemStack(1); + Bookim = Book.getItemMeta(); + Bookim.setDisplayName("§f§lBook"); + + arrowlore.add("§7Click to open the menu!"); + + Arrow = new MaterialData(Material.ARROW, (byte) 0).toItemStack(1); + Arrowim = Arrow.getItemMeta(); + Arrowim.setDisplayName("§f§lThrowing Knife"); + Arrowim.setLore(arrowlore); + Arrow.setItemMeta(Arrowim); + + Glow glow = new Glow(120); // 120 for custom enchant glow + + System.out.println("ItemStacks Builded!"); + commonMaterial = new MaterialData(Material.INK_SACK, (byte) 8).toItemStack(1); + ItemMeta commonMaterialim = commonMaterial.getItemMeta(); + commonMaterialim.setDisplayName("§7§lCommon Materials"); + commonMaterial.setItemMeta(commonMaterialim); + + commonMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 8).toItemStack(1); + ItemMeta commonMaterialGlowim = commonMaterialGlow.getItemMeta(); + commonMaterialGlowim.setDisplayName("§7§lCommon Materials"); + commonMaterialGlowim.addEnchant(glow, 1, true); + commonMaterialGlow.setItemMeta(commonMaterialGlowim); + + uncommonMaterial = new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1); + ItemMeta uncommonMaterialim = uncommonMaterial.getItemMeta(); + uncommonMaterialim.setDisplayName("§a§lUncommon Materials"); + uncommonMaterial.setItemMeta(uncommonMaterialim); + + uncommonMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1); + ItemMeta uncommonMaterialGlowim = uncommonMaterialGlow.getItemMeta(); + uncommonMaterialGlowim.addEnchant(glow, 1, true); + uncommonMaterialGlowim.setDisplayName("§a§lUncommon Materials"); + uncommonMaterialGlow.setItemMeta(uncommonMaterialGlowim); + + rareMaterial = new MaterialData(Material.INK_SACK, (byte) 12).toItemStack(1); + ItemMeta rareMaterialim = rareMaterial.getItemMeta(); + rareMaterialim.setDisplayName("§3§lRare Materials"); + rareMaterial.setItemMeta(rareMaterialim); + + rareMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 12).toItemStack(1); + ItemMeta rareMaterialGlowim = rareMaterialGlow.getItemMeta(); + rareMaterialGlowim.addEnchant(glow, 1, true); + rareMaterialGlowim.setDisplayName("§3§lRare Materials"); + rareMaterialGlow.setItemMeta(rareMaterialGlowim); + + epicMaterial = new MaterialData(Material.INK_SACK, (byte) 5).toItemStack(1); + ItemMeta epicMaterialim = epicMaterial.getItemMeta(); + epicMaterialim.setDisplayName("§5§lEpic Materials"); + epicMaterial.setItemMeta(epicMaterialim); + + epicMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 5).toItemStack(1); + ItemMeta epicMaterialGlowim = epicMaterialGlow.getItemMeta(); + epicMaterialGlowim.addEnchant(glow, 1, true); + epicMaterialGlowim.setDisplayName("§5§lEpic Materials"); + epicMaterialGlow.setItemMeta(epicMaterialGlowim); + + commonWeapons = new MaterialData(Material.INK_SACK, (byte) 15).toItemStack(1); + ItemMeta commonWeaponsim = commonWeapons.getItemMeta(); + commonWeaponsim.setDisplayName("§f§lCommon Weapons"); + commonWeapons.setItemMeta(commonWeaponsim); + + commonWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 15).toItemStack(1); + ItemMeta commonWeaponsGlowim = commonWeaponsGlow.getItemMeta(); + commonWeaponsGlowim.addEnchant(glow, 1, true); + commonWeaponsGlowim.setDisplayName("§f§lCommon Weapons"); + commonWeaponsGlow.setItemMeta(commonWeaponsGlowim); + + uncommonWeapons = new MaterialData(Material.INK_SACK, (byte) 2).toItemStack(1); + ItemMeta uncommonWeaponsim = uncommonWeapons.getItemMeta(); + uncommonWeaponsim.setDisplayName("§2§lUncommon Weapons"); + uncommonWeapons.setItemMeta(uncommonWeaponsim); + + uncommonWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 2).toItemStack(1); + ItemMeta uncommonWeaponsGlowim = uncommonWeaponsGlow.getItemMeta(); + uncommonWeaponsGlowim.addEnchant(glow, 1, true); + uncommonWeaponsGlowim.setDisplayName("§2§lUncommon Weapons"); + uncommonWeaponsGlow.setItemMeta(uncommonWeaponsGlowim); + + rareWeapons = new MaterialData(Material.INK_SACK, (byte) 4).toItemStack(1); + ItemMeta rareWeaponsim = rareWeapons.getItemMeta(); + rareWeaponsim.setDisplayName("§1§lRare Weapons"); + rareWeapons.setItemMeta(rareWeaponsim); + + rareWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 4).toItemStack(1); + ItemMeta rareWeaponsGlowim = rareWeaponsGlow.getItemMeta(); + rareWeaponsGlowim.addEnchant(glow, 1, true); + rareWeaponsGlowim.setDisplayName("§1§lRare Weapons"); + rareWeaponsGlow.setItemMeta(rareWeaponsGlowim); + + legendaryWeapons = new MaterialData(Material.INK_SACK, (byte) 11).toItemStack(1); + ItemMeta legendaryWeaponsim = legendaryWeapons.getItemMeta(); + legendaryWeaponsim.setDisplayName("§e§lLegendary Weapons"); + legendaryWeapons.setItemMeta(legendaryWeaponsim); + + legendaryWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 11).toItemStack(1); + ItemMeta legendaryWeaponsGlowim = legendaryWeaponsGlow.getItemMeta(); + legendaryWeaponsGlowim.addEnchant(glow, 1, true); + legendaryWeaponsGlowim.setDisplayName("§e§lLegendary Weapons"); + legendaryWeaponsGlow.setItemMeta(legendaryWeaponsGlowim); + + exclusiveWeapons = new MaterialData(Material.INK_SACK, (byte) 1).toItemStack(1); + ItemMeta exclusiveWeaponsim = exclusiveWeapons.getItemMeta(); + exclusiveWeaponsim.setDisplayName("§4§lExclusive Weapons"); + exclusiveWeapons.setItemMeta(exclusiveWeaponsim); + + exclusiveWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 1).toItemStack(1); + ItemMeta exclusiveWeaponsGlowim = exclusiveWeaponsGlow.getItemMeta(); + exclusiveWeaponsGlowim.addEnchant(glow, 1, true); + exclusiveWeaponsGlowim.setDisplayName("§4§lExclusive Weapons"); + exclusiveWeaponsGlow.setItemMeta(exclusiveWeaponsGlowim); + + glas = new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15).toItemStack(1); + ItemMeta glasim = glas.getItemMeta(); + glasim.setDisplayName(" "); + glas.setItemMeta(glasim); + + } + + private static void defaultinventory(Inventory inventory) { + inventory.setItem(0, new ItemStack(commonMaterial)); + inventory.setItem(1, new ItemStack(uncommonMaterial)); + inventory.setItem(2, new ItemStack(rareMaterial)); + inventory.setItem(3, new ItemStack(epicMaterial)); + inventory.setItem(4, new ItemStack(commonWeapons)); + inventory.setItem(5, new ItemStack(uncommonWeapons)); + inventory.setItem(6, new ItemStack(rareWeapons)); + inventory.setItem(7, new ItemStack(legendaryWeapons)); + inventory.setItem(8, new ItemStack(exclusiveWeapons)); + inventory.setItem(9, new ItemStack(glas)); + inventory.setItem(10, new ItemStack(glas)); + inventory.setItem(11, new ItemStack(glas)); + inventory.setItem(12, new ItemStack(glas)); + inventory.setItem(13, new ItemStack(glas)); + inventory.setItem(14, new ItemStack(glas)); + inventory.setItem(15, new ItemStack(glas)); + inventory.setItem(16, new ItemStack(glas)); + inventory.setItem(17, new ItemStack(glas)); + inventory.setItem(27, new ItemStack(glas)); + inventory.setItem(28, new ItemStack(glas)); + inventory.setItem(29, new ItemStack(glas)); + inventory.setItem(30, new ItemStack(glas)); + inventory.setItem(31, new ItemStack(glas)); + inventory.setItem(32, new ItemStack(glas)); + inventory.setItem(33, new ItemStack(glas)); + inventory.setItem(34, new ItemStack(glas)); + inventory.setItem(35, new ItemStack(glas)); + } + + public static void openGUIcommonMaterials(Player player) throws SQLException { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§7§lMaterials"); + defaultinventory(inventory); + inventory.setItem(0, new ItemStack(commonMaterialGlow)); + + PreparedStatement all = TestDatabase.mysql.getConnection().prepareStatement( + "Select `sticknumber`,`woodbuttonnumber`,`stonebuttonnumber`,`woodpreasureplatenumber`,`stonepreasureplatenumber`,`feathernumber`,`leathernumber`,`papernumber`,`booknumber` FROM `Materialnumber` WHERE `uuid` = \"" + + player.getUniqueId().toString() + "\""); + ResultSet rs = all.executeQuery(); + rs.next(); + + String StickNumber = Integer.toString(rs.getInt("sticknumber")); + String WoodbuttonNumber = Integer.toString(rs.getInt("woodbuttonnumber")); + String StonebuttonNumber = Integer.toString(rs.getInt("stonebuttonnumber")); + String WoodpreasureplateNumber = Integer.toString(rs.getInt("woodpreasureplatenumber")); + String StonepreasureplateNumber = Integer.toString(rs.getInt("stonepreasureplatenumber")); + String FeatherNumber = Integer.toString(rs.getInt("feathernumber")); + String LeatherNumber = Integer.toString(rs.getInt("leathernumber")); + String PaperNumber = Integer.toString(rs.getInt("papernumber")); + String BookNumber = Integer.toString(rs.getInt("booknumber")); + + List one = new ArrayList<>(); + one.add("§7§lYou have: §f§l" + StickNumber); + Stickim.setLore(one); + Stick.setItemMeta(Stickim); + inventory.setItem(18, new ItemStack(Stick)); + + List two = new ArrayList<>(); + two.add("§7§lYou have: §f§l" + WoodbuttonNumber); + Woodbuttonim.setLore(two); + Woodbutton.setItemMeta(Woodbuttonim); + inventory.setItem(19, new ItemStack(Woodbutton)); + + List three = new ArrayList<>(); + three.add("§7§lYou have: §f§l" + StonebuttonNumber); + Stonebuttonim.setLore(three); + Stonebutton.setItemMeta(Stonebuttonim); + inventory.setItem(20, new ItemStack(Stonebutton)); + + List four = new ArrayList<>(); + four.add("§7§lYou have: §f§l" + WoodpreasureplateNumber); + Woodpreasureplateim.setLore(four); + Woodpreasureplate.setItemMeta(Woodpreasureplateim); + inventory.setItem(21, new ItemStack(Woodpreasureplate)); + + List five = new ArrayList<>(); + five.add("§7§lYou have: §f§l" + StonepreasureplateNumber); + Stonepreasureplateim.setLore(five); + Stonepreasureplate.setItemMeta(Stonepreasureplateim); + inventory.setItem(22, new ItemStack(Stonepreasureplate)); + + List six = new ArrayList<>(); + six.add("§7§lYou have: §f§l" + FeatherNumber); + Featherim.setLore(six); + Feather.setItemMeta(Featherim); + inventory.setItem(23, new ItemStack(Feather)); + + List seven = new ArrayList<>(); + seven.add("§7§lYou have: §f§l" + LeatherNumber); + Leatherim.setLore(seven); + Leather.setItemMeta(Leatherim); + inventory.setItem(24, new ItemStack(Leather)); + + List eight = new ArrayList<>(); + eight.add("§7§lYou have: §f§l" + PaperNumber); + Paperim.setLore(eight); + Paper.setItemMeta(Paperim); + inventory.setItem(25, new ItemStack(Paper)); + + List nine = new ArrayList<>(); + nine.add("§7§lYou have: §f§l" + BookNumber); + Bookim.setLore(nine); + Book.setItemMeta(Bookim); + inventory.setItem(26, new ItemStack(Book)); + + player.openInventory(inventory); + + } + + public boolean DeadMeta(int clickedslot, String GUI_NAME) { + int Deadslot = 0; + if (GUI_NAME == "§7§lMaterials") { + Deadslot = 0; + } + if (GUI_NAME == "§a§lMaterials") { + Deadslot = 1; + } + if (GUI_NAME == "§3§lMaterials") { + Deadslot = 2; + } + if (GUI_NAME == "§5§lMaterials") { + Deadslot = 3; + } + if (GUI_NAME == "§f§lWeapons") { + Deadslot = 4; + } + if (GUI_NAME == "§2§lWeapons") { + Deadslot = 5; + } + if (GUI_NAME == "§1§lWeapons") { + Deadslot = 6; + } + if (GUI_NAME == "§e§lWeapons") { + Deadslot = 7; + } + if (GUI_NAME == "§4§lWeapons") { + Deadslot = 8; + } + + if (clickedslot == Deadslot) { + return true; + } + + return false; + + } + + @EventHandler + public void handleNavigatorGUIClickTop(InventoryClickEvent event) throws SQLException { + + if (!(event.getWhoClicked() instanceof Player)) + return; + + if (event.getClickedInventory() == null) + return; + + Player player = (Player) event.getWhoClicked(); + + if (!((event.getClickedInventory().getTitle().contains("Material") + || (event.getClickedInventory().getTitle().contains("Weapons"))))) + return; + + if (DeadMeta(event.getSlot(), event.getClickedInventory().getTitle()) == true) + return; + + if (event.getCurrentItem().getType() == Material.INK_SACK) { + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Uncommon Material")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§a§lMaterials"); + + defaultinventory(inventory); + inventory.setItem(1, new ItemStack(uncommonMaterialGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§7§lCommon Material")) { + + openGUIcommonMaterials(player); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§3§lRare Material")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§3§lMaterials"); + + defaultinventory(inventory); + inventory.setItem(2, new ItemStack(rareMaterialGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§5§lEpic Material")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§5§lMaterials"); + + defaultinventory(inventory); + inventory.setItem(3, new ItemStack(epicMaterialGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§f§lCommon Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§f§lWeapons"); + + defaultinventory(inventory); + + inventory.setItem(18, new ItemStack(Arrow)); + inventory.setItem(4, new ItemStack(commonWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§2§lUncommon Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§2§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(5, new ItemStack(uncommonWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§1§lRare Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§1§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(6, new ItemStack(rareWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§e§lLegendary Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§e§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(7, new ItemStack(legendaryWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§4§lExclusive Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§4§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(8, new ItemStack(exclusiveWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + } + + if (event.getCurrentItem().getItemMeta() == null) + return; + + + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Throwing Knife")) { + ArrowInventory(player); + return; + } + + + + + + if ((event.getCurrentItem().getItemMeta().getDisplayName().contains("Craft")) + && (event.getClickedInventory().getName().contains("Throwing Knife"))) { + ArrowCraft(player); + return; + } + + + + + if ((event.getCurrentItem().getItemMeta().getDisplayName().contains("Claim")) + && (event.getClickedInventory().getName().contains("Throwing Knife"))) + Claim(player); + + + + } + + private void Claim(Player player) throws SQLException { + int arrownumber; + PreparedStatement st; + st = TestDatabase.mysql.getConnection().prepareStatement( + "SELECT `number` FROM `Arrow` WHERE uuid = \"" + player.getUniqueId() + "\""); + + ResultSet rs = st.executeQuery(); + rs.next(); + arrownumber = rs.getInt("number"); + if (arrownumber < 1) + return; + + int arrowslot = getArrowSlot(player); + + if (arrowslot==-1) + return; + + + + player.getInventory().addItem(Arrow); + st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Arrow` SET `number` = ((Select `number` WHERE uuid =\"" + player.getUniqueId() + + "\")-1) WHERE uuid = \"" + player.getUniqueId() + "\""); + st.execute(); + ArrowInventory(player); + + } + + private void ArrowCraft(Player player) throws SQLException { + int sticknumber; + PreparedStatement st; + st = TestDatabase.mysql.getConnection().prepareStatement( + "SELECT `sticknumber` FROM `Materialnumber` WHERE uuid = \"" + player.getUniqueId() + "\""); + + ResultSet rs = st.executeQuery(); + rs.next(); + sticknumber = rs.getInt("sticknumber"); + + if (sticknumber < 2) { + return; + } + sticknumber = sticknumber - 2; + + st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Materialnumber` SET `sticknumber` = \"" + + sticknumber + "\" WHERE uuid = \"" + player.getUniqueId() + "\""); + + st.execute(); + + + + st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Arrow` SET `number` = ((Select `number` WHERE uuid =\"" + player.getUniqueId() + + "\")+1) WHERE uuid = \"" + player.getUniqueId() + "\""); + st.execute(); + + ArrowInventory(player); + } + + private void ArrowInventory(Player player) throws SQLException { + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§f§lWeapons > Throwing Knife"); + + PreparedStatement all = TestDatabase.mysql.getConnection() + .prepareStatement("SELECT number FROM `Arrow` WHERE uuid = \"" + player.getUniqueId() + "\""); + ResultSet rs = all.executeQuery(); + rs.next(); + + PreparedStatement allmaterials = TestDatabase.mysql.getConnection().prepareStatement( + "SELECT `sticknumber` FROM `Materialnumber` WHERE uuid = \"" + player.getUniqueId() + "\""); + ResultSet rs2 = allmaterials.executeQuery(); + rs2.next(); + + int sticknumber = rs2.getInt("sticknumber"); + int arrownumber = rs.getInt("number"); + + arrowlore.removeAll(arrowlore); + arrowlore.add("§7You have: §f" + arrownumber); + Arrowim.setLore(arrowlore); + Arrow.setItemMeta(Arrowim); + + inventory.setItem(4, new ItemStack(Arrow)); + + workbenchlore.removeAll(workbenchlore); + workbenchlore.add("§72x §lStick §7(§e" + sticknumber + "§7)"); + Workbenchim.setLore(workbenchlore); + Workbench.setItemMeta(Workbenchim); + inventory.setItem(20, new ItemStack(Workbench)); + + inventory.setItem(31, new ItemStack(Wool)); + + player.openInventory(inventory); + + arrowlore.removeAll(arrowlore); + arrowlore.add("§7Click to open the menu!"); + Arrowim.setLore(arrowlore); + Arrow.setItemMeta(Arrowim); + + } + + public static int getArrowSlot(Player player) { + for (int i = 0; i < 36; i++) { + ItemStack slot = player.getInventory().getItem(i); + if (slot.getType() != Material.AIR || (slot.getType() != Material.ARROW && slot.getAmount()<64)) + return i; + } + return -1; + } +} diff --git a/CollectionNew.java b/CollectionNew.java new file mode 100644 index 0000000..818cc53 --- /dev/null +++ b/CollectionNew.java @@ -0,0 +1,645 @@ +package de.luke.naruto; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.MaterialData; + +import de.luke.naruto.extras.Glow; +import de.luke.naruto.extras.TestDatabase; + +public class CollectionNew implements Listener { + + static ItemStack commonMaterialGlow; + static ItemStack commonMaterial; + static ItemStack uncommonMaterial; + static ItemStack uncommonMaterialGlow; + static ItemStack rareMaterial; + static ItemStack rareMaterialGlow; + static ItemStack epicMaterial; + static ItemStack epicMaterialGlow; + static ItemStack commonWeapons; + static ItemStack commonWeaponsGlow; + static ItemStack uncommonWeapons; + static ItemStack uncommonWeaponsGlow; + static ItemStack rareWeapons; + static ItemStack rareWeaponsGlow; + static ItemStack legendaryWeapons; + static ItemStack legendaryWeaponsGlow; + static ItemStack exclusiveWeapons; + static ItemStack exclusiveWeaponsGlow; + static ItemStack glas; + + static ItemStack Stick; + static ItemMeta Stickim; + + static ItemStack Woodbutton; + static ItemMeta Woodbuttonim; + + static ItemStack Stonebutton; + static ItemMeta Stonebuttonim; + + static ItemStack Woodpreasureplate; + static ItemMeta Woodpreasureplateim; + + static ItemStack Stonepreasureplate; + static ItemMeta Stonepreasureplateim; + + static ItemStack Feather; + static ItemMeta Featherim; + + static ItemStack Leather; + static ItemMeta Leatherim; + + static ItemStack Paper; + static ItemMeta Paperim; + + static ItemStack Book; + static ItemMeta Bookim; + + static List arrowlore = new ArrayList<>(); + + static ItemStack Arrow; + static ItemMeta Arrowim; + + static ItemStack Arrowamount; + static ItemMeta Arrowamountim; + + static List workbenchlore = new ArrayList<>(); + + static ItemStack Workbench; + static ItemMeta Workbenchim; + + static ItemStack Wool; + static ItemMeta Woolim; + + @SuppressWarnings("deprecation") + public static void Build() { + + ArrayList itemDatas = new ArrayList(); + itemDatas.add(new ItemData(Material.WORKBENCH, 0, "§f§lCraft")); + + Workbench = new MaterialData(Material.WORKBENCH, (byte) 0).toItemStack(1); + Workbenchim = Workbench.getItemMeta(); + Workbenchim.setDisplayName("§f§lCraft"); + + Wool = new MaterialData(Material.WOOL, (byte) 5).toItemStack(1); + Woolim = Wool.getItemMeta(); + Woolim.setDisplayName("§a§lClaim"); + Wool.setItemMeta(Woolim); + + Stick = new MaterialData(Material.STICK, (byte) 0).toItemStack(1); + Stickim = Stick.getItemMeta(); + Stickim.setDisplayName("§f§lStick"); + + Woodbutton = new MaterialData(Material.WOOD_BUTTON, (byte) 0).toItemStack(1); + Woodbuttonim = Woodbutton.getItemMeta(); + Woodbuttonim.setDisplayName("§f§lWooden Button"); + + Stonebutton = new MaterialData(Material.STONE_BUTTON, (byte) 0).toItemStack(1); + Stonebuttonim = Stonebutton.getItemMeta(); + Stonebuttonim.setDisplayName("§f§lStone Button"); + + Woodpreasureplate = new MaterialData(Material.WOOD_PLATE, (byte) 0).toItemStack(1); + Woodpreasureplateim = Woodpreasureplate.getItemMeta(); + Woodpreasureplateim.setDisplayName("§f§lWooden Pressure Plate"); + + Stonepreasureplate = new MaterialData(Material.STONE_PLATE, (byte) 0).toItemStack(1); + Stonepreasureplateim = Stonepreasureplate.getItemMeta(); + Stonepreasureplateim.setDisplayName("§f§lStone Pressure Plate"); + + Feather = new MaterialData(Material.FEATHER, (byte) 0).toItemStack(1); + Featherim = Feather.getItemMeta(); + Featherim.setDisplayName("§f§lFeather"); + + Leather = new MaterialData(Material.LEATHER, (byte) 0).toItemStack(1); + Leatherim = Leather.getItemMeta(); + Leatherim.setDisplayName("§f§lLeather"); + + Paper = new MaterialData(Material.PAPER, (byte) 0).toItemStack(1); + Paperim = Paper.getItemMeta(); + Paperim.setDisplayName("§f§lPaper"); + + Book = new MaterialData(Material.BOOK, (byte) 0).toItemStack(1); + Bookim = Book.getItemMeta(); + Bookim.setDisplayName("§f§lBook"); + + arrowlore.add("§7Click to open the menu!"); + + Arrow = new MaterialData(Material.ARROW, (byte) 0).toItemStack(1); + Arrowim = Arrow.getItemMeta(); + Arrowim.setDisplayName("§f§lThrowing Knife"); + Arrowim.setLore(arrowlore); + Arrow.setItemMeta(Arrowim); + + Glow glow = new Glow(120); // 120 for custom enchant glow + + System.out.println("ItemStacks Builded!"); + commonMaterial = new MaterialData(Material.INK_SACK, (byte) 8).toItemStack(1); + ItemMeta commonMaterialim = commonMaterial.getItemMeta(); + commonMaterialim.setDisplayName("§7§lCommon Materials"); + commonMaterial.setItemMeta(commonMaterialim); + + commonMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 8).toItemStack(1); + ItemMeta commonMaterialGlowim = commonMaterialGlow.getItemMeta(); + commonMaterialGlowim.setDisplayName("§7§lCommon Materials"); + commonMaterialGlowim.addEnchant(glow, 1, true); + commonMaterialGlow.setItemMeta(commonMaterialGlowim); + + uncommonMaterial = new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1); + ItemMeta uncommonMaterialim = uncommonMaterial.getItemMeta(); + uncommonMaterialim.setDisplayName("§a§lUncommon Materials"); + uncommonMaterial.setItemMeta(uncommonMaterialim); + + uncommonMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1); + ItemMeta uncommonMaterialGlowim = uncommonMaterialGlow.getItemMeta(); + uncommonMaterialGlowim.addEnchant(glow, 1, true); + uncommonMaterialGlowim.setDisplayName("§a§lUncommon Materials"); + uncommonMaterialGlow.setItemMeta(uncommonMaterialGlowim); + + rareMaterial = new MaterialData(Material.INK_SACK, (byte) 12).toItemStack(1); + ItemMeta rareMaterialim = rareMaterial.getItemMeta(); + rareMaterialim.setDisplayName("§3§lRare Materials"); + rareMaterial.setItemMeta(rareMaterialim); + + rareMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 12).toItemStack(1); + ItemMeta rareMaterialGlowim = rareMaterialGlow.getItemMeta(); + rareMaterialGlowim.addEnchant(glow, 1, true); + rareMaterialGlowim.setDisplayName("§3§lRare Materials"); + rareMaterialGlow.setItemMeta(rareMaterialGlowim); + + epicMaterial = new MaterialData(Material.INK_SACK, (byte) 5).toItemStack(1); + ItemMeta epicMaterialim = epicMaterial.getItemMeta(); + epicMaterialim.setDisplayName("§5§lEpic Materials"); + epicMaterial.setItemMeta(epicMaterialim); + + epicMaterialGlow = new MaterialData(Material.INK_SACK, (byte) 5).toItemStack(1); + ItemMeta epicMaterialGlowim = epicMaterialGlow.getItemMeta(); + epicMaterialGlowim.addEnchant(glow, 1, true); + epicMaterialGlowim.setDisplayName("§5§lEpic Materials"); + epicMaterialGlow.setItemMeta(epicMaterialGlowim); + + commonWeapons = new MaterialData(Material.INK_SACK, (byte) 15).toItemStack(1); + ItemMeta commonWeaponsim = commonWeapons.getItemMeta(); + commonWeaponsim.setDisplayName("§f§lCommon Weapons"); + commonWeapons.setItemMeta(commonWeaponsim); + + commonWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 15).toItemStack(1); + ItemMeta commonWeaponsGlowim = commonWeaponsGlow.getItemMeta(); + commonWeaponsGlowim.addEnchant(glow, 1, true); + commonWeaponsGlowim.setDisplayName("§f§lCommon Weapons"); + commonWeaponsGlow.setItemMeta(commonWeaponsGlowim); + + uncommonWeapons = new MaterialData(Material.INK_SACK, (byte) 2).toItemStack(1); + ItemMeta uncommonWeaponsim = uncommonWeapons.getItemMeta(); + uncommonWeaponsim.setDisplayName("§2§lUncommon Weapons"); + uncommonWeapons.setItemMeta(uncommonWeaponsim); + + uncommonWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 2).toItemStack(1); + ItemMeta uncommonWeaponsGlowim = uncommonWeaponsGlow.getItemMeta(); + uncommonWeaponsGlowim.addEnchant(glow, 1, true); + uncommonWeaponsGlowim.setDisplayName("§2§lUncommon Weapons"); + uncommonWeaponsGlow.setItemMeta(uncommonWeaponsGlowim); + + rareWeapons = new MaterialData(Material.INK_SACK, (byte) 4).toItemStack(1); + ItemMeta rareWeaponsim = rareWeapons.getItemMeta(); + rareWeaponsim.setDisplayName("§1§lRare Weapons"); + rareWeapons.setItemMeta(rareWeaponsim); + + rareWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 4).toItemStack(1); + ItemMeta rareWeaponsGlowim = rareWeaponsGlow.getItemMeta(); + rareWeaponsGlowim.addEnchant(glow, 1, true); + rareWeaponsGlowim.setDisplayName("§1§lRare Weapons"); + rareWeaponsGlow.setItemMeta(rareWeaponsGlowim); + + legendaryWeapons = new MaterialData(Material.INK_SACK, (byte) 11).toItemStack(1); + ItemMeta legendaryWeaponsim = legendaryWeapons.getItemMeta(); + legendaryWeaponsim.setDisplayName("§e§lLegendary Weapons"); + legendaryWeapons.setItemMeta(legendaryWeaponsim); + + legendaryWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 11).toItemStack(1); + ItemMeta legendaryWeaponsGlowim = legendaryWeaponsGlow.getItemMeta(); + legendaryWeaponsGlowim.addEnchant(glow, 1, true); + legendaryWeaponsGlowim.setDisplayName("§e§lLegendary Weapons"); + legendaryWeaponsGlow.setItemMeta(legendaryWeaponsGlowim); + + exclusiveWeapons = new MaterialData(Material.INK_SACK, (byte) 1).toItemStack(1); + ItemMeta exclusiveWeaponsim = exclusiveWeapons.getItemMeta(); + exclusiveWeaponsim.setDisplayName("§4§lExclusive Weapons"); + exclusiveWeapons.setItemMeta(exclusiveWeaponsim); + + exclusiveWeaponsGlow = new MaterialData(Material.INK_SACK, (byte) 1).toItemStack(1); + ItemMeta exclusiveWeaponsGlowim = exclusiveWeaponsGlow.getItemMeta(); + exclusiveWeaponsGlowim.addEnchant(glow, 1, true); + exclusiveWeaponsGlowim.setDisplayName("§4§lExclusive Weapons"); + exclusiveWeaponsGlow.setItemMeta(exclusiveWeaponsGlowim); + + glas = new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15).toItemStack(1); + ItemMeta glasim = glas.getItemMeta(); + glasim.setDisplayName(" "); + glas.setItemMeta(glasim); + + } + + private static void defaultinventory(Inventory inventory) { + inventory.setItem(0, new ItemStack(commonMaterial)); + inventory.setItem(1, new ItemStack(uncommonMaterial)); + inventory.setItem(2, new ItemStack(rareMaterial)); + inventory.setItem(3, new ItemStack(epicMaterial)); + inventory.setItem(4, new ItemStack(commonWeapons)); + inventory.setItem(5, new ItemStack(uncommonWeapons)); + inventory.setItem(6, new ItemStack(rareWeapons)); + inventory.setItem(7, new ItemStack(legendaryWeapons)); + inventory.setItem(8, new ItemStack(exclusiveWeapons)); + inventory.setItem(9, new ItemStack(glas)); + inventory.setItem(10, new ItemStack(glas)); + inventory.setItem(11, new ItemStack(glas)); + inventory.setItem(12, new ItemStack(glas)); + inventory.setItem(13, new ItemStack(glas)); + inventory.setItem(14, new ItemStack(glas)); + inventory.setItem(15, new ItemStack(glas)); + inventory.setItem(16, new ItemStack(glas)); + inventory.setItem(17, new ItemStack(glas)); + inventory.setItem(27, new ItemStack(glas)); + inventory.setItem(28, new ItemStack(glas)); + inventory.setItem(29, new ItemStack(glas)); + inventory.setItem(30, new ItemStack(glas)); + inventory.setItem(31, new ItemStack(glas)); + inventory.setItem(32, new ItemStack(glas)); + inventory.setItem(33, new ItemStack(glas)); + inventory.setItem(34, new ItemStack(glas)); + inventory.setItem(35, new ItemStack(glas)); + } + + public static void openGUIcommonMaterials(Player player) throws SQLException { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§7§lMaterials"); + defaultinventory(inventory); + inventory.setItem(0, new ItemStack(commonMaterialGlow)); + + PreparedStatement all = TestDatabase.mysql.getConnection().prepareStatement( + "Select `sticknumber`,`woodbuttonnumber`,`stonebuttonnumber`,`woodpreasureplatenumber`,`stonepreasureplatenumber`,`feathernumber`,`leathernumber`,`papernumber`,`booknumber` FROM `Materialnumber` WHERE `uuid` = \"" + + player.getUniqueId().toString() + "\""); + ResultSet rs = all.executeQuery(); + rs.next(); + + String StickNumber = Integer.toString(rs.getInt("sticknumber")); + String WoodbuttonNumber = Integer.toString(rs.getInt("woodbuttonnumber")); + String StonebuttonNumber = Integer.toString(rs.getInt("stonebuttonnumber")); + String WoodpreasureplateNumber = Integer.toString(rs.getInt("woodpreasureplatenumber")); + String StonepreasureplateNumber = Integer.toString(rs.getInt("stonepreasureplatenumber")); + String FeatherNumber = Integer.toString(rs.getInt("feathernumber")); + String LeatherNumber = Integer.toString(rs.getInt("leathernumber")); + String PaperNumber = Integer.toString(rs.getInt("papernumber")); + String BookNumber = Integer.toString(rs.getInt("booknumber")); + + List one = new ArrayList<>(); + one.add("§7§lYou have: §f§l" + StickNumber); + Stickim.setLore(one); + Stick.setItemMeta(Stickim); + inventory.setItem(18, new ItemStack(Stick)); + + List two = new ArrayList<>(); + two.add("§7§lYou have: §f§l" + WoodbuttonNumber); + Woodbuttonim.setLore(two); + Woodbutton.setItemMeta(Woodbuttonim); + inventory.setItem(19, new ItemStack(Woodbutton)); + + List three = new ArrayList<>(); + three.add("§7§lYou have: §f§l" + StonebuttonNumber); + Stonebuttonim.setLore(three); + Stonebutton.setItemMeta(Stonebuttonim); + inventory.setItem(20, new ItemStack(Stonebutton)); + + List four = new ArrayList<>(); + four.add("§7§lYou have: §f§l" + WoodpreasureplateNumber); + Woodpreasureplateim.setLore(four); + Woodpreasureplate.setItemMeta(Woodpreasureplateim); + inventory.setItem(21, new ItemStack(Woodpreasureplate)); + + List five = new ArrayList<>(); + five.add("§7§lYou have: §f§l" + StonepreasureplateNumber); + Stonepreasureplateim.setLore(five); + Stonepreasureplate.setItemMeta(Stonepreasureplateim); + inventory.setItem(22, new ItemStack(Stonepreasureplate)); + + List six = new ArrayList<>(); + six.add("§7§lYou have: §f§l" + FeatherNumber); + Featherim.setLore(six); + Feather.setItemMeta(Featherim); + inventory.setItem(23, new ItemStack(Feather)); + + List seven = new ArrayList<>(); + seven.add("§7§lYou have: §f§l" + LeatherNumber); + Leatherim.setLore(seven); + Leather.setItemMeta(Leatherim); + inventory.setItem(24, new ItemStack(Leather)); + + List eight = new ArrayList<>(); + eight.add("§7§lYou have: §f§l" + PaperNumber); + Paperim.setLore(eight); + Paper.setItemMeta(Paperim); + inventory.setItem(25, new ItemStack(Paper)); + + List nine = new ArrayList<>(); + nine.add("§7§lYou have: §f§l" + BookNumber); + Bookim.setLore(nine); + Book.setItemMeta(Bookim); + inventory.setItem(26, new ItemStack(Book)); + + player.openInventory(inventory); + + } + + public boolean DeadMeta(int clickedslot, String GUI_NAME) { + int Deadslot = 0; + if (GUI_NAME == "§7§lMaterials") { + Deadslot = 0; + } + if (GUI_NAME == "§a§lMaterials") { + Deadslot = 1; + } + if (GUI_NAME == "§3§lMaterials") { + Deadslot = 2; + } + if (GUI_NAME == "§5§lMaterials") { + Deadslot = 3; + } + if (GUI_NAME == "§f§lWeapons") { + Deadslot = 4; + } + if (GUI_NAME == "§2§lWeapons") { + Deadslot = 5; + } + if (GUI_NAME == "§1§lWeapons") { + Deadslot = 6; + } + if (GUI_NAME == "§e§lWeapons") { + Deadslot = 7; + } + if (GUI_NAME == "§4§lWeapons") { + Deadslot = 8; + } + + if (clickedslot == Deadslot) { + return true; + } + + return false; + + } + + @EventHandler + public void handleNavigatorGUIClickTop(InventoryClickEvent event) throws SQLException { + + if (!(event.getWhoClicked() instanceof Player)) + return; + + if (event.getClickedInventory() == null) + return; + + Player player = (Player) event.getWhoClicked(); + + if (!((event.getClickedInventory().getTitle().contains("Material") + || (event.getClickedInventory().getTitle().contains("Weapons"))))) + return; + + if (DeadMeta(event.getSlot(), event.getClickedInventory().getTitle()) == true) + return; + + if (event.getCurrentItem().getType() == Material.INK_SACK) { + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Uncommon Material")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§a§lMaterials"); + + defaultinventory(inventory); + inventory.setItem(1, new ItemStack(uncommonMaterialGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§7§lCommon Material")) { + + openGUIcommonMaterials(player); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§3§lRare Material")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§3§lMaterials"); + + defaultinventory(inventory); + inventory.setItem(2, new ItemStack(rareMaterialGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§5§lEpic Material")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§5§lMaterials"); + + defaultinventory(inventory); + inventory.setItem(3, new ItemStack(epicMaterialGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§f§lCommon Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§f§lWeapons"); + + defaultinventory(inventory); + + inventory.setItem(18, new ItemStack(Arrow)); + inventory.setItem(4, new ItemStack(commonWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§2§lUncommon Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§2§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(5, new ItemStack(uncommonWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§1§lRare Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§1§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(6, new ItemStack(rareWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§e§lLegendary Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§e§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(7, new ItemStack(legendaryWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§4§lExclusive Weapons")) { + + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§4§lWeapons"); + + defaultinventory(inventory); + inventory.setItem(8, new ItemStack(exclusiveWeaponsGlow)); + player.openInventory(inventory); + + return; + } + + } + + if (event.getCurrentItem().getItemMeta() == null) + return; + + if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Throwing Knife")) { + ArrowInventory(player); + return; + } + + if ((event.getCurrentItem().getItemMeta().getDisplayName().contains("Craft")) + && (event.getClickedInventory().getName().contains("Throwing Knife"))) { + ArrowCraft(player); + return; + } + + if ((event.getCurrentItem().getItemMeta().getDisplayName().contains("Claim")) + && (event.getClickedInventory().getName().contains("Throwing Knife"))) + Claim(player); + + } + + private void Claim(Player player) throws SQLException { + int arrownumber; + PreparedStatement st; + st = TestDatabase.mysql.getConnection() + .prepareStatement("SELECT `number` FROM `Arrow` WHERE uuid = \"" + player.getUniqueId() + "\""); + + ResultSet rs = st.executeQuery(); + rs.next(); + arrownumber = rs.getInt("number"); + if (arrownumber < 1) + return; + + int arrowslot = getArrowSlot(player); + + if (arrowslot == -1) + return; + + player.getInventory().addItem(Arrow); + st = TestDatabase.mysql.getConnection() + .prepareStatement("UPDATE `Arrow` SET `number` = ((Select `number` WHERE uuid =\"" + + player.getUniqueId() + "\")-1) WHERE uuid = \"" + player.getUniqueId() + "\""); + st.execute(); + ArrowInventory(player); + + } + + private void ArrowCraft(Player player) throws SQLException { + int sticknumber; + PreparedStatement st; + st = TestDatabase.mysql.getConnection().prepareStatement( + "SELECT `sticknumber` FROM `Materialnumber` WHERE uuid = \"" + player.getUniqueId() + "\""); + + ResultSet rs = st.executeQuery(); + rs.next(); + sticknumber = rs.getInt("sticknumber"); + + if (sticknumber < 2) { + return; + } + sticknumber = sticknumber - 2; + + st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Materialnumber` SET `sticknumber` = \"" + + sticknumber + "\" WHERE uuid = \"" + player.getUniqueId() + "\""); + + st.execute(); + + st = TestDatabase.mysql.getConnection() + .prepareStatement("UPDATE `Arrow` SET `number` = ((Select `number` WHERE uuid =\"" + + player.getUniqueId() + "\")+1) WHERE uuid = \"" + player.getUniqueId() + "\""); + st.execute(); + + ArrowInventory(player); + } + + private void ArrowInventory(Player player) throws SQLException { + Inventory inventory = Bukkit.createInventory(null, 9 * 4, "§f§lWeapons > Throwing Knife"); + + PreparedStatement all = TestDatabase.mysql.getConnection() + .prepareStatement("SELECT number FROM `Arrow` WHERE uuid = \"" + player.getUniqueId() + "\""); + ResultSet rs = all.executeQuery(); + rs.next(); + + PreparedStatement allmaterials = TestDatabase.mysql.getConnection().prepareStatement( + "SELECT `sticknumber` FROM `Materialnumber` WHERE uuid = \"" + player.getUniqueId() + "\""); + ResultSet rs2 = allmaterials.executeQuery(); + rs2.next(); + + int sticknumber = rs2.getInt("sticknumber"); + int arrownumber = rs.getInt("number"); + + arrowlore.removeAll(arrowlore); + arrowlore.add("§7You have: §f" + arrownumber); + Arrowim.setLore(arrowlore); + Arrow.setItemMeta(Arrowim); + + inventory.setItem(4, new ItemStack(Arrow)); + + workbenchlore.removeAll(workbenchlore); + workbenchlore.add("§72x §lStick §7(§e" + sticknumber + "§7)"); + Workbenchim.setLore(workbenchlore); + Workbench.setItemMeta(Workbenchim); + inventory.setItem(20, new ItemStack(Workbench)); + + inventory.setItem(31, new ItemStack(Wool)); + + player.openInventory(inventory); + + arrowlore.removeAll(arrowlore); + arrowlore.add("§7Click to open the menu!"); + Arrowim.setLore(arrowlore); + Arrow.setItemMeta(Arrowim); + + } + + public static int getArrowSlot(Player player) { + for (int i = 0; i < 36; i++) { + ItemStack slot = player.getInventory().getItem(i); + if (slot.getType() != Material.AIR || (slot.getType() != Material.ARROW && slot.getAmount() < 64)) + return i; + } + return -1; + } +} diff --git a/ItemData.java b/ItemData.java new file mode 100644 index 0000000..e0515b4 --- /dev/null +++ b/ItemData.java @@ -0,0 +1,22 @@ +package de.luke.naruto; + +import org.bukkit.Material; + +public class ItemData { + + public ItemData(Material material, int byteValue, String displayName) { + _material = material; + _byteValue = (byte) byteValue; + _displayName = displayName; + + } + + private Material _material; + private byte _byteValue; + private String _displayName; + + /* + * public ItemStack GetItemStack() { return _itemStack; + */ + +} diff --git a/Level.java b/Level.java new file mode 100644 index 0000000..a368ab8 --- /dev/null +++ b/Level.java @@ -0,0 +1,99 @@ +package de.luke.naruto; //TODO Mehrere Level Gleichzeitig hoch + + +import java.io.File; +import java.io.IOException; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; + +public class Level implements Listener{ + + +//public void PlayerJoin(PlayerLoginEvent event) { +// Player p = event.getPlayer(); +// if(!p.hasPlayedBefore()) { + +// } +//} + + + + @EventHandler + public void onDeath(EntityDeathEvent e) { + Entity entity = e.getEntity(); + Entity killer = e.getEntity().getKiller(); + + + if (killer instanceof Player) { + + + String playerName = killer.getName(); + File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase"); + File f = new File(userdata, File.separator + playerName + ".yml"); + FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); + + int before = Calculator.level(playerData.getInt("xplevel.balance")); + + if (entity.getType() == EntityType.ZOMBIE); + int x = playerData.getInt("xplevel.balance") + 10; + + playerData.set("xplevel.balance", x); + + int after = Calculator.level(playerData.getInt("xplevel.balance")); + + if (before != after) { + killer.sendMessage("§a§lCongratulations! You leveld up " + before + " §a§l--> " + after); + if (after < 26) { + int y = playerData.getInt("force") + 1; + playerData.set("force", y); + killer.sendMessage("§c§lForce + 1"); + + + } else + if (after < 101) { + int y1 = playerData.getInt("force") + 2; + playerData.set("force", y1); + killer.sendMessage("§c§lForce + 2"); + } + else { + int y2 = playerData.getInt("force") + 3; + playerData.set("force", y2); + killer.sendMessage("§c§lForce + 3"); + } + + } + + + + try { + playerData.save(f); + } catch (IOException e1) { + + e1.printStackTrace(); + } + + + + + + + } + } + + + + + + + } + + + diff --git a/PlayerList.java b/PlayerList.java new file mode 100644 index 0000000..d445896 --- /dev/null +++ b/PlayerList.java @@ -0,0 +1,57 @@ +package de.luke.naruto; + +import java.io.File; +import java.io.IOException; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class PlayerList implements Listener { + + + + + + + + + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + player.sendMessage("§aWilkommen"); + String playerName = player.getName(); + File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase"); + File f = new File(userdata, File.separator + playerName + ".yml"); + FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); + + int x = playerData.getInt("stats.totalLogins") + 1; + playerData.set("stats.totalLogins", x); + + if (playerData.getInt("xplevel.balance") < 100) { + playerData.set("xplevel.balance", 100); + } + + if (playerData.getInt("force") < 1) { + playerData.set("force", 1); + + + } + + try { + playerData.save(f); + } catch (IOException e) { + + e.printStackTrace(); + } + + + +} + +} diff --git a/commands/Broadcast.java b/commands/Broadcast.java new file mode 100644 index 0000000..8c2822a --- /dev/null +++ b/commands/Broadcast.java @@ -0,0 +1,54 @@ +package de.luke.naruto.commands; + + + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Broadcast implements CommandExecutor{ + + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { +if(sender instanceof Player) { + Player player = (Player) sender; + + + if (player.isOp() == true) { + if ((args.length > 0) && (args.length < 9) ) { + Bukkit.broadcastMessage(" "); + Bukkit.broadcastMessage(" "); + + if (args.length == 1 ) { + Bukkit.broadcastMessage("§f§l" + args[0]);} + if (args.length == 2 ) { + Bukkit.broadcastMessage("§f§l" + args[0] +" "+ args[1]);} + if (args.length == 3 ) { + Bukkit.broadcastMessage("§f§l" + args[0] +" "+ args[1] + " "+args[2]);} + if (args.length == 4 ) { + Bukkit.broadcastMessage("§f§l" + args[0] +" "+ args[1] +" "+ args[2] + " "+args[3]);} + if (args.length == 5 ) { + Bukkit.broadcastMessage("§f§l" + args[0] + " "+args[1] + " "+args[2] +" "+ args[3] + " "+args[4]);} + if (args.length == 6 ) { + Bukkit.broadcastMessage("§f§l" + args[0] + " "+args[1] +" "+ args[2] + " "+args[3] + " "+args[4] +" "+ args[5]);} + if (args.length == 7 ) { + Bukkit.broadcastMessage("§f§l" + args[0] + " "+args[1] + " "+args[2] + " "+args[3] +" "+ args[4] + " "+args[5] + " "+args[6]);} + if (args.length == 8 ) { + Bukkit.broadcastMessage("§f§l" + args[0] + " "+args[1] + " "+args[2] +" "+ args[3] + " "+args[4] + " "+args[5] +" "+ args[6] +" "+ args[7]);} + + Bukkit.broadcastMessage(" "); + Bukkit.broadcastMessage(" "); + } else player.sendMessage("§f§lUse /Broadcast [Message (Max 8 Words)]"); + } else sender.sendMessage("§c§lInsufficent Permissions"); + + + + + + + +} else sender.sendMessage("§cCommand only for Console and Player!"); + return false; + } +} diff --git a/commands/Bypass.java b/commands/Bypass.java new file mode 100644 index 0000000..f07c957 --- /dev/null +++ b/commands/Bypass.java @@ -0,0 +1,127 @@ +package de.luke.naruto.commands; + + + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import de.luke.naruto.extras.TestDatabase; + +public class Bypass implements CommandExecutor { + + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + if(player.hasPermission("bypass.*")) { + if(args.length == 0) { + try { + if ((isInDatabase(player.getUniqueId().toString()))) { //Update in isInDatabase + + if (isBypassed(player.getUniqueId().toString()) == true) { + + try { + setBypass(player.getUniqueId().toString(), false); + sender.sendMessage("§cNot Bypassing permissions anymore."); + + } catch (SQLException e) { + e.printStackTrace(); + sender.sendMessage("§cDatabank Error"); + } + + } else { + sender.sendMessage("§aBypassing permissions now."); + + try { + setBypass(player.getUniqueId().toString(), true); + } catch (SQLException e) { + e.printStackTrace(); + } + + } + + } else { + sender.sendMessage("§aBypassing permissions now."); + System.out.println("New Databank Player bypass listing"); + + try { + setBypass(player.getUniqueId().toString(), true); + } catch (SQLException e) { + e.printStackTrace(); + } + + } + + + } catch (SQLException e1) { + System.out.println("§fDatabank Error"); + e1.printStackTrace(); + } + + + + + } else player.sendMessage("§cUse /Bypass"); + + + } else sender.sendMessage("§cYou can not perform this command"); + +} else sender.sendMessage("§cCommand only for Players!"); + return false; + } + + public static void setBypass(String uuid, boolean bypassenabled) throws SQLException { + PreparedStatement st = null; + if (isInDatabase(uuid)) { //Update in isInDatabase + st = TestDatabase.mysql.getSafeConnection().prepareStatement("UPDATE `BypassInfo` SET `bypassenabled` = ? WHERE `uuid` = ?"); + st.setBoolean(1, bypassenabled); + st.setString(2, uuid); + st.execute(); + } else { + st = TestDatabase.mysql.getConnection().prepareStatement("INSERT INTO `BypassInfo`(`uuid`,`bypassenabled`) VALUES (?,?)"); + st.setString(1, uuid); + st.setBoolean(2, bypassenabled); + st.execute(); + } + + } + + + + + + public static boolean isInDatabase(String uuid) throws SQLException { + PreparedStatement st = TestDatabase.mysql.getConnection().prepareStatement("Select `uuid` FROM `BypassInfo` WHERE `uuid` = ?"); + st.setString(1, uuid); + ResultSet rs = st.executeQuery(); + + + while(rs.next()) { + return true; + } + return false; + + + + +} + + public static boolean isBypassed(String uuid) throws SQLException { + boolean isbypassed = false; + if (isInDatabase(uuid)) { + PreparedStatement st = TestDatabase.mysql.getSafeConnection().prepareStatement("Select `bypassenabled` FROM `BypassInfo` WHERE `uuid` = ?"); + st.setString(1, uuid); + ResultSet rs = st.executeQuery(); + while (rs.next()) { + isbypassed = rs.getBoolean("bypassenabled"); + + + } + } + return isbypassed; +} +} diff --git a/commands/Claim.java b/commands/Claim.java new file mode 100644 index 0000000..427b3c2 --- /dev/null +++ b/commands/Claim.java @@ -0,0 +1,114 @@ +package de.luke.naruto.commands; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import de.luke.naruto.extras.TestDatabase; + +public class Claim implements CommandExecutor { + + PreparedStatement st; + ItemStack item1 = new ItemStack(Material.STICK); + + + ItemStack item2 = new ItemStack(Material.WOOD_BUTTON); + + + ItemStack item3 = new ItemStack(Material.STONE_BUTTON); + + + ItemStack item4 = new ItemStack(Material.WOOD_PLATE); + + + ItemStack item5 = new ItemStack(Material.STONE_PLATE); + + + ItemStack item6 = new ItemStack(Material.FEATHER); + + + ItemStack item7 = new ItemStack(Material.LEATHER); + + + ItemStack item8 = new ItemStack(Material.PAPER); + + + ItemStack item9 = new ItemStack(Material.BOOK); + + + + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length == 0) { + + + + ItemStack itemamount1 = new ItemStack(Material.STICK, getAmount(player, item1)); + ItemStack itemamount2 = new ItemStack(Material.WOOD_BUTTON, getAmount(player, item2)); + ItemStack itemamount3 = new ItemStack(Material.STONE_BUTTON, getAmount(player, item3)); + ItemStack itemamount4 = new ItemStack(Material.WOOD_PLATE, getAmount(player, item4)); + ItemStack itemamount5 = new ItemStack(Material.STONE_PLATE, getAmount(player, item5)); + ItemStack itemamount6 = new ItemStack(Material.FEATHER, getAmount(player, item6)); + ItemStack itemamount7 = new ItemStack(Material.LEATHER, getAmount(player, item7)); + ItemStack itemamount8 = new ItemStack(Material.PAPER, getAmount(player, item8)); + ItemStack itemamount9 = new ItemStack(Material.BOOK, getAmount(player, item9)); + + try { + st = TestDatabase.mysql.getConnection().prepareStatement("UPDATE `Materialnumber` SET `sticknumber` = ("+getAmount(player, item1)+"+(Select `sticknumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")),`woodbuttonnumber` = ("+getAmount(player, item2)+"+(Select `woodbuttonnumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")),`stonebuttonnumber` = ("+getAmount(player, item3)+"+(Select `stonebuttonnumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")), `woodpreasureplatenumber` = ("+getAmount(player, item4)+"+(Select `woodpreasureplatenumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")), `stonepreasureplatenumber` = ("+getAmount(player, item5)+"+(Select `stonepreasureplatenumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")), `feathernumber` = ("+getAmount(player, item6)+"+(Select `feathernumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")), `leathernumber` = ("+getAmount(player, item7)+"+(Select `leathernumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")), `papernumber` = ("+getAmount(player, item8)+"+(Select `papernumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")), `booknumber` = ("+getAmount(player, item9)+"+(Select `booknumber` WHERE `uuid` = \""+player.getUniqueId().toString()+"\")) WHERE `uuid` = \""+player.getUniqueId().toString()+"\""); + st.execute(); + + + } catch (SQLException e) { + player.sendMessage("§cDatabank error please contact an Admin"); + System.out.println("§cDatabank error Player:" + player.getName()); + e.printStackTrace(); + + } + + player.getInventory().removeItem(itemamount1); + player.getInventory().removeItem(itemamount2); + player.getInventory().removeItem(itemamount3); + player.getInventory().removeItem(itemamount4); + player.getInventory().removeItem(itemamount5); + player.getInventory().removeItem(itemamount6); + player.getInventory().removeItem(itemamount7); + player.getInventory().removeItem(itemamount8); + player.getInventory().removeItem(itemamount9); + + + + + + player.sendMessage("§F§lYou used your /Claim! Materials from your inventory were added to your §4§lCollection!"); + + //TODO else Cooldown + + + } else sender.sendMessage("Please Use /claim"); + +} else sender.sendMessage("§cCommand only for Players!"); + return false; + } + + + +public static int getAmount(Player player, ItemStack item) { + if (item == null) + return 0; + int amount = 0; + for (int i = 0; i < 36; i++) { + ItemStack slot = player.getInventory().getItem(i); + if (slot == null || !slot.isSimilar(item)) + continue; + amount += slot.getAmount(); + } + return amount; +} +} diff --git a/commands/ClearChat.java b/commands/ClearChat.java new file mode 100644 index 0000000..92aabe6 --- /dev/null +++ b/commands/ClearChat.java @@ -0,0 +1,30 @@ +package de.luke.naruto.commands; + + + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.entity.Player; + +public class ClearChat implements CommandExecutor{ + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { +if ((sender instanceof ConsoleCommandSender) || (sender instanceof Player) ) { + + int i= 0; + while (i < 50) { + Bukkit.broadcastMessage(""); + i++;} + + + + + +} else sender.sendMessage("§cCommand only for Console and Player!"); + return false; + } +} diff --git a/commands/EnumTest.java b/commands/EnumTest.java new file mode 100644 index 0000000..89f4535 --- /dev/null +++ b/commands/EnumTest.java @@ -0,0 +1,5 @@ +package de.luke.naruto.commands; + +public enum EnumTest { + +} diff --git a/commands/Force.java b/commands/Force.java new file mode 100644 index 0000000..c5f795f --- /dev/null +++ b/commands/Force.java @@ -0,0 +1,27 @@ +package de.luke.naruto.commands; + +import java.io.File; + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +public class Force implements CommandExecutor { + + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + String playerName = player.getName(); + File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase"); + File f = new File(userdata, File.separator + playerName + ".yml"); + FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); + sender.sendMessage("§c§lForce: "+ (playerData.getInt("force"))); + +} else sender.sendMessage("§cCommand only for Players!"); + return false; + } +} diff --git a/commands/ThrowingAxe.java b/commands/ThrowingAxe.java new file mode 100644 index 0000000..f2e3d98 --- /dev/null +++ b/commands/ThrowingAxe.java @@ -0,0 +1,33 @@ +package de.luke.naruto.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import customweapons.ItemManager; + +public class ThrowingAxe implements CommandExecutor { + + + + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] arg1) { + if(sender instanceof Player) { + Player player = (Player) sender; + if (player.isOp()) { + if(command.getName().equalsIgnoreCase("givethrowingaxe")) { + player.getInventory().addItem(ItemManager.ThrowingAxe); + } + } + + } else { + sender.sendMessage("§cOnly Players can use this command"); + } + return true; + } + +} + + diff --git a/extras/CreateGlow.java b/extras/CreateGlow.java new file mode 100644 index 0000000..eb96a99 --- /dev/null +++ b/extras/CreateGlow.java @@ -0,0 +1,30 @@ +package de.luke.naruto.extras; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class CreateGlow implements Listener { + + ItemStack item = new ItemStack(Material.STICK); + ItemMeta itemMeta = item.getItemMeta(); + + + + @EventHandler + public void PlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + Glow glow = new Glow(120); + itemMeta.addEnchant(glow, 1, true); + item.setItemMeta(itemMeta); + + player.getInventory().addItem(item); + player.updateInventory(); + } + + +} diff --git a/extras/Glow.java b/extras/Glow.java new file mode 100644 index 0000000..b0e0c09 --- /dev/null +++ b/extras/Glow.java @@ -0,0 +1,74 @@ +package de.luke.naruto.extras; + + + +import java.lang.reflect.Field; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; + + +public class Glow extends Enchantment implements Listener { + + public Glow(int id) { + super(id); + } //set to 120 + + @Override + public boolean canEnchantItem(ItemStack arg0) { + return false; + } + + @Override + public boolean conflictsWith(Enchantment arg0) { + return false; + } + + @Override + public EnchantmentTarget getItemTarget() { + return null; + } + + @Override + public int getMaxLevel() { + return 0; + } + + @Override + public String getName() { + return null; + } + + @Override + public int getStartLevel() { + return 0; + } + + + public static void registerGlow() { + try { + Field f = Enchantment.class.getDeclaredField("acceptingNew"); + f.setAccessible(true); + f.set(null, true); + } + catch (Exception e) { + e.printStackTrace(); + } + try { + Glow glow = new Glow(120); + Enchantment.registerEnchantment(glow); + } + catch (IllegalArgumentException e){ + } + catch(Exception e){ + e.printStackTrace(); + } + } + + + +} + + \ No newline at end of file diff --git a/extras/MySQL.java b/extras/MySQL.java new file mode 100644 index 0000000..ebfe2c1 --- /dev/null +++ b/extras/MySQL.java @@ -0,0 +1,108 @@ +package de.luke.naruto.extras; + + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + + + + +public class MySQL { + + + + + private Connection con; + + private String host; + private int port; + private String database; + private String user; + private String password; + + public MySQL(String host, int port, String database, String user, String password) { + + this.host = host; + this.port = port; + this.database = database; + this.user = user; + this.password = password; + + connect(); + + } + + + public void connect() { + + + + try { + con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true", user, password); + + System.out.println("MySQL connected"); + + } catch (SQLException e) { + e.printStackTrace(); + System.out.println("MySQL disconnected"); + } + + } + + public void disconnect() { + + + try { + if (this.hasConnection()) { + this.con.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + + public boolean hasConnection() { + if(this.con != null) { + return true; + } return false; + } + + public void UpdateConnection() throws SQLException { + + + if (con.isValid(0) == false) { + + + disconnect(); + connect(); + System.out.println("NewConnection"); + + + + + + } + } + + + public Connection getConnection() throws SQLException { + if (con.isValid(0) == false) { + + + disconnect(); + connect(); + + } + return this.con; + } + + +public Connection getSafeConnection() { + return this.con; +} +} + + + diff --git a/extras/TestDatabase.java b/extras/TestDatabase.java new file mode 100644 index 0000000..d77a11e --- /dev/null +++ b/extras/TestDatabase.java @@ -0,0 +1,20 @@ +package de.luke.naruto.extras; + + +public class TestDatabase { + + + public static MySQL mysql; + + public static void setUp() { + loadMySQL(); + + } + + //https://webphpmyadmin.com/ + + public static void loadMySQL() { + mysql = new MySQL("remotemysql.com", 3306, "PLScCERvj5", "PLScCERvj5", "5SQVjPa69W"); + } + +} diff --git a/main/Main.java b/main/Main.java new file mode 100644 index 0000000..b8ef8e4 --- /dev/null +++ b/main/Main.java @@ -0,0 +1,71 @@ +package de.luke.naruto.main; + + +import org.bukkit.Bukkit; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; + +import de.luke.naruto.BindItems; +import de.luke.naruto.Calculator; +import de.luke.naruto.Collection; +import de.luke.naruto.Level; +import de.luke.naruto.PlayerList; +import de.luke.naruto.commands.Broadcast; +import de.luke.naruto.commands.Bypass; +import de.luke.naruto.commands.Claim; +import de.luke.naruto.commands.ClearChat; +import de.luke.naruto.commands.Force; +import de.luke.naruto.commands.ThrowingAxe; +import de.luke.naruto.extras.CreateGlow; +import de.luke.naruto.extras.Glow; +import de.luke.naruto.extras.TestDatabase; +import de.luke.naruto.weapons.WeaponHandler; + +public class Main extends JavaPlugin { + + public static Main plugin; + + public void onEnable() { + plugin = this; + PluginManager pluginManager = Bukkit.getPluginManager(); + pluginManager.registerEvents(new WeaponHandler(this), this); + System.out.println("Ninja Plugin Enabled"); + getServer().getPluginManager().registerEvents(new PlayerList(), this); + getServer().getPluginManager().registerEvents(new Level(), this); + getServer().getPluginManager().registerEvents(new BindItems(), this); + getServer().getPluginManager().registerEvents(new Collection(), this); + getServer().getPluginManager().registerEvents(new CreateGlow(), this); + + getCommand("level").setExecutor(new Calculator()); + getCommand("force").setExecutor(new Force()); + getCommand("bypass").setExecutor(new Bypass()); + getCommand("clearchat").setExecutor(new ClearChat()); + getCommand("cc").setExecutor(new ClearChat()); + getCommand("broadcast").setExecutor(new Broadcast()); + getCommand("bc").setExecutor(new Broadcast()); + getCommand("claim").setExecutor(new Claim()); + getCommand("givethrowingaxe").setExecutor(new ThrowingAxe()); + + Collection.Build(); + + + Glow.registerGlow(); + TestDatabase.loadMySQL(); + + } + + //Broadcast Welcome Message in BindItems + + + + + public static Main getPlugin() { + return plugin; + + + } + + + + +} diff --git a/program/Boot.java b/program/Boot.java new file mode 100644 index 0000000..aadf916 --- /dev/null +++ b/program/Boot.java @@ -0,0 +1,24 @@ +package de.luke.naruto.program; + + +public class Boot { + + public static void main(String[] args) { + + if (Zufallszahl.Zufall() > 10) { + hello("Max", Zufallszahl.Zufall()); + + }else {hello("Tom", Zufallszahl.Zufall());} + + + } + + public static void hello(String name, int age) { + + String hello = "Guten Tag! Mein Name ist " + name + " und ich bin " + age + " Jahre alt."; + System.out.println(hello); + } + +} + + diff --git a/program/Zufallszahl.java b/program/Zufallszahl.java new file mode 100644 index 0000000..22ac18c --- /dev/null +++ b/program/Zufallszahl.java @@ -0,0 +1,18 @@ +package de.luke.naruto.program; + +import java.util.Random; + +public class Zufallszahl { + + + public static int Zufall() { + + Random zufall = new Random(); + int zufallsZahl = zufall.nextInt(20); + return zufallsZahl + 1; + + + } + +} + diff --git a/weapons/Launcher.java b/weapons/Launcher.java new file mode 100644 index 0000000..ff59a4d --- /dev/null +++ b/weapons/Launcher.java @@ -0,0 +1,26 @@ +package de.luke.naruto.weapons; + +import org.bukkit.Material; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.Player; + +import de.luke.naruto.main.Main; + +public class Launcher extends Weapon { + + public Launcher(Main plugin, Material material, long reloadTime, double damage) { + super(plugin, material, reloadTime, damage); + + } + + @Override + public void shootEffects(Player player) { + Fireball projectile = player.launchProjectile(Fireball.class); //projectile nur ein Name kann auch z.B Ball heißen + projectile.setIsIncendiary(false); + projectile.setYield(0f); + projectile.setVelocity(projectile.getVelocity().multiply(2)); + + + } + +} diff --git a/weapons/Rifle.java b/weapons/Rifle.java new file mode 100644 index 0000000..ea80538 --- /dev/null +++ b/weapons/Rifle.java @@ -0,0 +1,23 @@ +package de.luke.naruto.weapons; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; + +import de.luke.naruto.main.Main; + +public class Rifle extends Weapon { + + public Rifle(Main plugin, Material material, long reloadTime, double damage) { + super(plugin, material, reloadTime, damage); + + } + + @Override + public void shootEffects(Player player) { + Snowball projectile = player.launchProjectile(Snowball.class); + projectile.setVelocity(projectile.getVelocity().multiply(7)); + + } + +} diff --git a/weapons/Test.java b/weapons/Test.java new file mode 100644 index 0000000..80eafa5 --- /dev/null +++ b/weapons/Test.java @@ -0,0 +1,23 @@ +package de.luke.naruto.weapons; + +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; + +import de.luke.naruto.main.Main; + +public class Test extends Weapon { + + public Test(Main plugin, Material material, long reloadTime, double damage) { + super(plugin, material, reloadTime, damage); + + } + + @Override + public void shootEffects(Player player) { + Arrow projectile = player.launchProjectile(Arrow.class); + projectile.setVelocity(projectile.getVelocity().multiply(1.5)); + + } + +} \ No newline at end of file diff --git a/weapons/Weapon.java b/weapons/Weapon.java new file mode 100644 index 0000000..225ad74 --- /dev/null +++ b/weapons/Weapon.java @@ -0,0 +1,65 @@ +package de.luke.naruto.weapons; + +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import de.luke.naruto.main.Main; + +public abstract class Weapon { + + private Main plugin; + private Material material; + private long reloadTime; + private ArrayList shotWeapon; + public static String playerName; + private double damage; + + + public Weapon(Main plugin, Material material, long reloadTime, double damage) { + super(); + this.plugin = plugin; + this.material = material; + this.reloadTime = reloadTime; + this.damage = damage; + + shotWeapon = new ArrayList<>(); + } + + public void shoot(Player player) { + if(!shotWeapon.contains(player.getName())) { + shotWeapon.add(player.getName()); + playerName = player.getName(); + shootEffects(player); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + shotWeapon.remove(player.getName()); + } + + + }, reloadTime); + } + + } + + public abstract void shootEffects(Player player); + + public Material getMaterial() { + return material; + } + + public double getDamage() { + return damage; + } + + + + + + +} diff --git a/weapons/WeaponHandler.java b/weapons/WeaponHandler.java new file mode 100644 index 0000000..64a6c3b --- /dev/null +++ b/weapons/WeaponHandler.java @@ -0,0 +1,90 @@ +package de.luke.naruto.weapons; + +import java.io.File; +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +import de.luke.naruto.main.Main; + + +public class WeaponHandler implements Listener { + + private ArrayList weapons; + + public WeaponHandler(Main plugin) { + + weapons = new ArrayList<>(); + weapons.add(new Rifle(plugin, Material.IRON_HOE, 10, 2.0)); + weapons.add(new Launcher(plugin, Material.GOLD_HOE, 20*5, 10)); + weapons.add(new Test(plugin, Material.ARROW, 20, 10)); + + + } + + + @EventHandler + public void handleWeaponShot(PlayerInteractEvent event) { + if(event.getAction() != Action.RIGHT_CLICK_AIR) return; + Weapon weapon = checkWeaponMaterial(event.getItem().getType()); + if(weapon != null) { + weapon.shoot(event.getPlayer()); + + } + + + } + + @EventHandler + public void handleWeaponDamage(EntityDamageByEntityEvent event) { + + if(!(event.getDamager() instanceof Projectile)) return; + Projectile projectile = (Projectile) event.getDamager(); + if(!(projectile.getShooter() instanceof Player)) return; + Player player = (Player) projectile.getShooter(); + Weapon weapon = checkWeaponMaterial(player.getItemInHand().getType()); + + if(weapon!= null) { + + String playerName = Weapon.playerName; + File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase"); + File f = new File(userdata, File.separator + playerName + ".yml"); + FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); + + event.setDamage(weapon.getDamage() + 1 *(playerData.getInt("force")) / 10); + } + + } + + private Weapon checkWeaponMaterial(Material material) { + for(Weapon current : weapons) { + if(current.getMaterial() == material) { + return current; + } + + + } return null; + + + } + @EventHandler + public void onArrowHit(ProjectileHitEvent event){ + if(event.getEntity() instanceof Arrow){ + Arrow arrow = (Arrow) event.getEntity(); + arrow.remove(); + } + } + +}