Java Code Examples for org.bukkit.Material#DIAMOND_AXE

The following examples show how to use org.bukkit.Material#DIAMOND_AXE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCategories.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testAddItem() {
    Category category = new Category(new NamespacedKey(plugin, "items_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing"));
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_ITEMS_TEST_ITEM", new CustomItem(Material.BAMBOO, "&6Test Bamboo"));
    item.setCategory(category);
    item.register(plugin);
    item.load();

    Assertions.assertTrue(category.getItems().contains(item));
    Assertions.assertEquals(1, category.getItems().size());

    // Size must still be 1 since we disallow duplicates
    item.setCategory(category);

    Assertions.assertEquals(1, category.getItems().size());
    Assertions.assertThrows(IllegalArgumentException.class, () -> category.add(null));
}
 
Example 2
Source File: TierSetSpawner.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
public static void spawnTierItem(int tierLevel, Player player) {

        ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
        ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
        ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
        ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
        ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
        ItemStack axe = new ItemStack(Material.DIAMOND_AXE);
        ItemStack bow = new ItemStack(Material.BOW);

        if (tierLevel > 1) {

            applyEnchantment(helmet, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(chestplate, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(leggings, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(boots, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(sword, Enchantment.DAMAGE_ALL, tierLevel);
            applyEnchantment(axe, Enchantment.DAMAGE_ALL, tierLevel);
            applyEnchantment(bow, Enchantment.ARROW_DAMAGE, tierLevel);

        }

        player.getInventory().addItem(helmet);
        player.getInventory().addItem(chestplate);
        player.getInventory().addItem(leggings);
        player.getInventory().addItem(boots);
        player.getInventory().addItem(sword);
        player.getInventory().addItem(axe);
        player.getInventory().addItem(bow);

        return;

    }
 
Example 3
Source File: DoubleDamageEvent.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
public DoubleDamageEvent(GameMap map, boolean b) {
	this.gMap = map;
	this.enabled = b;
	File dataDirectory = SkyWarsReloaded.get().getDataFolder();
       File mapDataDirectory = new File(dataDirectory, "mapsData");

       if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) {
       	return;
       }
       
       File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml");
    if (mapFile.exists()) {
    	eventName = "DoubleDamageEvent";
    	slot = 15;
    	material = new ItemStack(Material.DIAMOND_AXE, 1);
        FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile);
        this.min = fc.getInt("events." + eventName + ".minStart");
        this.max = fc.getInt("events." + eventName + ".maxStart");
        this.length = fc.getInt("events." + eventName + ".length");
        this.chance = fc.getInt("events." + eventName + ".chance");
        this.title = fc.getString("events." + eventName + ".title");
        this.subtitle = fc.getString("events." + eventName + ".subtitle");
        this.startMessage = fc.getString("events." + eventName + ".startMessage");
        this.endMessage = fc.getString("events." + eventName + ".endMessage");
        this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer");
        this.repeatable = fc.getBoolean("events." + eventName + ".repeatable");
    }
}
 
Example 4
Source File: TestCategories.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testCategoryGetters() {
    Category category = new Category(new NamespacedKey(plugin, "getter_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing"));

    Assertions.assertEquals(3, category.getTier());
    Assertions.assertEquals(new NamespacedKey(SlimefunPlugin.instance, "getter_test"), category.getKey());
    Assertions.assertEquals("Testing", category.getUnlocalizedName());
    Assertions.assertEquals(0, category.getItems().size());
}
 
Example 5
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadAmmo(QAMain main) {

		if (new File(main.getDataFolder(), "ammo").exists()) {
			int items = 0;
			for (File f : new File(main.getDataFolder(), "ammo").listFiles()) {
				try {
					if (f.getName().contains("yml")) {
						FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
						if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
							Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
									: Material.DIAMOND_AXE;
							int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
							final String name = f2.getString("name");
							if(QAMain.verboseLoadingLogging)
							main.getLogger().info("-Loading AmmoType: " + name);

							String extraData = null;
							if (f2.contains("skull_owner")) {
								extraData = f2.getString("skull_owner");
							}
							String ed2 = null;
							if (f2.contains("skull_owner_custom_url")
									&& !f2.getString("skull_owner_custom_url").equals(Ammo.NO_SKIN_STRING)) {
								ed2 = f2.getString("skull_owner_custom_url");
							}

							final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant, extraData,
									ed2);
							final ItemStack[] materails = main
									.convertIngredients(f2.getStringList("craftingRequirements"));
							final String displayname = f2.contains("displayname")
									? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
									: (ChatColor.WHITE + name);
							final List<String> extraLore2 = f2.contains("lore") ? f2.getStringList("lore") : null;
							final List<String> extraLore = new ArrayList<String>();
							try {
								for (String lore : extraLore2) {
									extraLore.add(ChatColor.translateAlternateColorCodes('&', lore));
								}
							} catch (Error | Exception re52) {
							}

							final double price = f2.contains("price") ? f2.getDouble("price") : 100;

							int amountA = f2.getInt("maxAmount");

							double piercing = f2.getDouble("piercingSeverity");

							Ammo da = new Ammo(name, displayname, extraLore, ms, amountA, false, 1, price, materails,
									piercing);

							da.setCustomLore(extraLore);

							QAMain.ammoRegister.put(ms, da);
							items++;

							if (extraData != null) {
								da.setSkullOwner(extraData);
							}
							if (ed2 != null) {
								da.setCustomSkin(ed2);
							}
							if (f2.contains("craftingReturnAmount")) {
								da.setCraftingReturn(f2.getInt("craftingReturnAmount"));
							}

						}
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if(!QAMain.verboseLoadingLogging)
				main.getLogger().info("-Loaded "+items+" Ammo types.");


		}
	}
 
Example 6
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadArmor(QAMain main) {
	if (new File(main.getDataFolder(), "armor").exists()) {
		int items = 0;

		for (File f : new File(main.getDataFolder(), "armor").listFiles()) {
			try {
				if (f.getName().contains("yml")) {
					FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
					if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
						final String name = f2.getString("name");
						if(QAMain.verboseLoadingLogging)
						main.getLogger().info("-Loading Armor: " + name);

						Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
								: Material.DIAMOND_AXE;
						int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
						final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant);
						final ItemStack[] materails = main
								.convertIngredients(f2.getStringList("craftingRequirements"));
						final String displayname = f2.contains("displayname")
								? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
								: (ChatColor.WHITE + name);
						final List<String> rawLore = f2.contains("lore") ? f2.getStringList("lore") : null;
						final List<String> lore = new ArrayList<String>();
						try {
							for (String lore2 : rawLore) {
								lore.add(ChatColor.translateAlternateColorCodes('&', lore2));
							}
						} catch (Error | Exception re52) {
						}

						final int price = f2.contains("price") ? f2.getInt("price") : 100;

						WeaponType wt = WeaponType.getByName(f2.getString("MiscType"));

						if (wt == WeaponType.HELMET) {
							QAMain.armorRegister.put(ms, new Helmet(name, displayname, lore, materails, ms, price));
							items++;
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if(!QAMain.verboseLoadingLogging)
			main.getLogger().info("-Loaded "+items+" Armor types.");
	}
}
 
Example 7
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadMisc(QAMain main) {
	if (new File(main.getDataFolder(), "misc").exists()) {
		int items = 0;
		for (File f : new File(main.getDataFolder(), "misc").listFiles()) {
			try {
				if (f.getName().contains("yml")) {
					FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
					if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
						final String name = f2.getString("name");
						if (QAMain.verboseLoadingLogging)
							main.getLogger().info("-Loading Misc: " + name);

						Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
								: Material.DIAMOND_AXE;
						int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
						final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant);
						final ItemStack[] materails = main
								.convertIngredients(f2.getStringList("craftingRequirements"));
						final String displayname = f2.contains("displayname")
								? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
								: (ChatColor.WHITE + name);
						final List<String> rawLore = f2.contains("lore") ? f2.getStringList("lore") : null;
						final List<String> lore = new ArrayList<String>();
						try {
							for (String lore2 : rawLore) {
								lore.add(ChatColor.translateAlternateColorCodes('&', lore2));
							}
						} catch (Error | Exception re52) {
						}

						final int price = f2.contains("price") ? f2.getInt("price") : 100;

						int damage = f2.contains("damage") ? f2.getInt("damage") : 1;
						// int durib = f2.contains("durability") ? f2.getInt("durability") : 1000;

						WeaponType wt = WeaponType.getByName(f2.getString("MiscType"));

						double radius = f2.contains("radius") ? f2.getDouble("radius") : 0;
						items++;

						CustomBaseObject base = null;


						String soundEquip =  f2.contains("sound_equip")? f2.getString("sound_equip"):null;
						String soundHit =  f2.contains("sound_meleehit")? f2.getString("sound_meleehit"):null;

						if (wt == WeaponType.MEDKIT)
							QAMain.miscRegister.put(ms, base=new MedKit(ms, name, displayname, materails, price));
						if (wt == WeaponType.MELEE) {
							QAMain.miscRegister.put(ms,
									base = new MeleeItems(ms, name, displayname, materails, price, damage));
							base.setSoundOnEquip(soundEquip);
							base.setSoundOnHit(soundHit);
							base.setCustomLore(lore);
						}
						if (wt == WeaponType.GRENADES)
							QAMain.miscRegister.put(ms,
									base=new Grenade(materails, price, damage, radius, name, displayname, lore, ms));
						if (wt == WeaponType.SMOKE_GRENADES)
							QAMain.miscRegister.put(ms, base=new SmokeGrenades(materails, price, damage, radius, name,
									displayname, lore, ms));
						if (wt == WeaponType.INCENDARY_GRENADES)
							QAMain.miscRegister.put(ms, base=new IncendaryGrenades(materails, price, damage, radius,
									name, displayname, lore, ms));
						if (wt == WeaponType.FLASHBANGS)
							QAMain.miscRegister.put(ms,
									base=new Flashbang(materails, price, damage, radius, name, displayname, lore, ms));

						if(base!=null) {
							base.setCustomLore(lore);
							base.setIngredients(materails);
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if(!QAMain.verboseLoadingLogging)
			main.getLogger().info("-Loaded "+items+" Misc.");
	}
}
 
Example 8
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadGuns(QAMain main, File f) {
		if (f.getName().contains("yml")) {
			FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
			if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
				final String name = f2.getString("name");
				if(QAMain.verboseLoadingLogging)
				main.getLogger().info("-Loading Gun: " + name);

				Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
						: Material.DIAMOND_AXE;
				int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
				final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant);
				WeaponType weatype = f2.contains("guntype") ? WeaponType.valueOf(f2.getString("guntype"))
						: WeaponType.valueOf(f2.getString("weapontype"));
				final ItemStack[] materails = main.convertIngredients(f2.getStringList("craftingRequirements"));

				final String displayname = f2.contains("displayname")
						? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
						: (ChatColor.GOLD + name);
				final List<String> extraLore2 = f2.contains("lore") ? f2.getStringList("lore") : null;
				final List<String> extraLore = new ArrayList<String>();

				try {
					for (String lore : extraLore2) {
						extraLore.add(ChatColor.translateAlternateColorCodes('&', lore));
					}
				} catch (Error | Exception re52) {
				}
				if (weatype.isGun()) {
					Gun g = new Gun(name, ms);
					g.setDisplayname(displayname);
					g.setCustomLore(extraLore);
					g.setIngredients(materails);
					QAMain.gunRegister.put(ms, g);
					loadGunSettings(g, f2);
				}

			}
		}

}
 
Example 9
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadAttachments(QAMain main) {
	if (new File(main.getDataFolder(), "attachments").exists()) {
		int items = 0;
		for (File f : new File(main.getDataFolder(), "attachments").listFiles()) {
			try {
				if (f.getName().contains("yml")) {
					FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
					if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
						final String name = f2.getString("name");
						main.getLogger().info("-Loading Attachment: " + name);
						final String displayname = f2.contains("displayname")
								? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
								: (ChatColor.GOLD + name);
						final List<String> extraLore2 = f2.contains("lore") ? f2.getStringList("lore") : null;

						Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
								: Material.DIAMOND_AXE;
						int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
						final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant);

						// Gun baseGun = null;
						MaterialStorage baseGunM = null;
						String base = f2.getString("baseGun");
						for (Entry<MaterialStorage, Gun> g : QAMain.gunRegister.entrySet()) {
							if (g.getValue().getName().equalsIgnoreCase(base)) {
								// baseGun = g.getValue();
								baseGunM = g.getKey();
							}
						}

						final List<String> extraLore = new ArrayList<String>();
						try {
							for (String lore : extraLore2) {
								extraLore.add(ChatColor.translateAlternateColorCodes('&', lore));
							}
						} catch (Error | Exception re52) {
						}
						if(baseGunM==null){
							main.getLogger().info("--Failed to load "+name+" attachment because the base \""+base+"\" does not exist.");
							continue;
						}

						AttachmentBase attach = new AttachmentBase(baseGunM, ms, name, displayname);
						QAMain.gunRegister.put(ms, attach);
						items++;

						attach.setCustomLore(extraLore);

						final Object[] materials = main
								.convertIngredientsRaw(f2.getStringList("craftingRequirements"));
						attach.setIngredientsRaw(materials);

						// QAMain.attachmentRegister.put(ms, attach);
						loadGunSettings(attach, f2);
					}

				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if(!QAMain.verboseLoadingLogging)
			main.getLogger().info("-Loaded "+items+" Attachment types.");
	}
}
 
Example 10
Source File: InteractListener.java    From SaneEconomy with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onPlayerInteract(PlayerInteractEvent evt) {
    if (!evt.getPlayer().hasPermission("saneeconomy.signshop.use")) {
        return;
    }

    if (evt.getHand() != EquipmentSlot.HAND) {
        return;
    }

    if ((evt.getPlayer().getInventory().getItemInMainHand() != null) && (evt.getPlayer().getInventory().getItemInMainHand().getType() == Material.DIAMOND_AXE)) {
        return;
    }

    if ((evt.getAction() != Action.RIGHT_CLICK_BLOCK) && (evt.getAction() != Action.LEFT_CLICK_BLOCK)) {
        return;
    }

    Optional<SignShop> shopOptional = this.plugin.getSignShopManager().getSignShop(evt.getClickedBlock().getLocation());

    if (!shopOptional.isPresent()) {
        return;
    }

    SignShop shop = shopOptional.get();

    // Buy
    if (evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
        evt.setCancelled(true);
        if (!shop.canBuy()) {
            this.plugin.getMessenger().sendMessage(evt.getPlayer(), "This shop does not permit buying.");
            return;
        }

        this.doBuy(shop, evt.getPlayer());
    }

    // Sell
    if (evt.getAction() == Action.LEFT_CLICK_BLOCK) {
        evt.setCancelled(true);
        if (!shop.canSell()) {
            this.plugin.getMessenger().sendMessage(evt.getPlayer(), "This shop does not permit selling.");
            return;
        }

        this.doSell(shop, evt.getPlayer());
    }
}
 
Example 11
Source File: GenericSuperAxe.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
protected GenericSuperAxe(String slug, String name) {
	super(slug, name, Material.DIAMOND_AXE);
}