org.bukkit.Material#ANVIL源码实例Demo

下面列出了org.bukkit.Material#ANVIL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: UhcCore   文件: InfiniteEnchantsListener.java
@EventHandler
public void onGameStarted(UhcStartedEvent e){
    ItemStack enchantingTables = UniversalMaterial.ENCHANTING_TABLE.getStack(64);
    ItemStack anvils = new ItemStack(Material.ANVIL, 64);
    ItemStack lapisBlocks = new ItemStack(Material.LAPIS_BLOCK, 64);

    for (UhcPlayer uhcPlayer : e.getPlayersManager().getOnlinePlayingPlayers()){
        try {
            Player player = uhcPlayer.getPlayer();
            player.getInventory().addItem(enchantingTables, anvils, lapisBlocks);
            player.setLevel(Integer.MAX_VALUE);
        }catch (UhcPlayerNotOnlineException ex){
            // No rod for offline players
        }
    }
}
 
源代码2 项目: Civs   文件: CivilianListener.java
@EventHandler(ignoreCancelled = true)
public void onCivilianUseExp(PlayerInteractEvent event) {
    if (event.getClickedBlock() == null || event.getAction() != Action.RIGHT_CLICK_BLOCK) {
        return;
    }
    Civilian civilian = CivilianManager.getInstance().getCivilian(event.getPlayer().getUniqueId());
    if (civilian.getMana() < 1 || civilian.getMana() > 99) {
        return;
    }
    Material mat = event.getClickedBlock().getType();
    if (mat == Material.ANVIL ||
            mat == Material.ENCHANTING_TABLE) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslationWithPlaceholders(
                event.getPlayer(), "mana-use-exp"));
    }
}
 
源代码3 项目: UhcCore   文件: GoneFishingListener.java
@EventHandler
public void onGameStarted(UhcStartedEvent e){
    ItemStack rod = new ItemStack(Material.FISHING_ROD);
    rod.addUnsafeEnchantment(Enchantment.LURE, lureLevel);
    rod.addUnsafeEnchantment(Enchantment.LUCK, luckLevel);

    ItemMeta meta = rod.getItemMeta();
    VersionUtils.getVersionUtils().setItemUnbreakable(meta, true);
    rod.setItemMeta(meta);

    ItemStack anvils = new ItemStack(Material.ANVIL, 64);

    for (UhcPlayer uhcPlayer : e.getPlayersManager().getOnlinePlayingPlayers()){
        try {
            // Give the rod
            uhcPlayer.getPlayer().getInventory().addItem(rod);

            // Give player 10000 xl levels
            uhcPlayer.getPlayer().setLevel(10000);

            // Give player 64 anvils
            uhcPlayer.getPlayer().getInventory().addItem(anvils);
        }catch (UhcPlayerNotOnlineException ex){
            // No rod for offline players
        }
    }
}
 
源代码4 项目: SkyWarsReloaded   文件: AnvilRainEvent.java
public AnvilRainEvent(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 = "AnvilRainEvent";
    	slot = 0;
    	material = new ItemStack(Material.ANVIL, 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");
        this.per5Tick = fc.getInt("events." + eventName + ".spawnPer5Tick");
       }
}
 
源代码5 项目: Slimefun4   文件: ArmorForge.java
public ArmorForge(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { 
          null, null, null, 
          null, new ItemStack(Material.ANVIL), null, 
          null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null 
    }, new ItemStack[0], BlockFace.SELF);
}
 
源代码6 项目: PGM   文件: AnvilTracker.java
@EventHandler(priority = EventPriority.MONITOR)
public void onPlace(ParticipantBlockTransformEvent event) {
  if (event.getNewState().getMaterial() == Material.ANVIL) {
    blocks().trackBlockState(event.getNewState(), new AnvilInfo(event.getPlayerState()));
  }
}
 
源代码7 项目: MineTinker   文件: BlockListener.java
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onClick(PlayerInteractEvent event) {
	Player player = event.getPlayer();

	ItemStack norm = null;
	if (event.getHand() == EquipmentSlot.HAND) {
		norm = player.getInventory().getItemInMainHand();
	} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
		norm = player.getInventory().getItemInOffHand();
	}

	if (norm == null) return;

	if (event.getAction() == Action.RIGHT_CLICK_AIR) {
		if (modManager.isModifierItem(norm)) {
			event.setCancelled(true);
		}
	} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
		Block block = event.getClickedBlock();

		if (block == null) {
			return;
		}
		if (!player.isSneaking()) {
			Material type = block.getType();

			if (type == Material.ANVIL || type == Material.CRAFTING_TABLE
					|| type == Material.CHEST || type == Material.ENDER_CHEST
					|| type == Material.DROPPER || type == Material.HOPPER
					|| type == Material.DISPENSER || type == Material.TRAPPED_CHEST
					|| type == Material.FURNACE || type == Material.ENCHANTING_TABLE) {

				return;
			}
		}

		if (modManager.isModifierItem(norm)) {
			event.setCancelled(true);
			return;
		}

		if (block.getType() == Material.getMaterial(MineTinker.getPlugin().getConfig().getString("BlockToEnchantModifiers", Material.BOOKSHELF.name()))) {
			ItemStack item = player.getInventory().getItemInMainHand();

			for (Modifier m : modManager.getAllMods()) {
				if (m.getModItem().getType().equals(item.getType())) {
					if (!m.isEnchantable()) continue;
					m.enchantItem(player);
					event.setCancelled(true);
					break;
				}
			}
		}
	}
}
 
源代码8 项目: ProjectAres   文件: AnvilTracker.java
@EventHandler(priority = EventPriority.MONITOR)
public void onPlace(ParticipantBlockTransformEvent event) {
    if(event.getNewState().getMaterial() == Material.ANVIL) {
        blocks().trackBlockState(event.getNewState(), new AnvilInfo(event.getPlayerState()));
    }
}
 
源代码9 项目: ProRecipes   文件: Recipes.java
public boolean handleDoubles(ItemStack[] items, ItemStack result, Player p, Inventory inv){
	//long mil = System.currentTimeMillis();
	RecipeShapeless r = new RecipeShapeless(new ItemStack(Material.ANVIL));
	
	for(ItemStack i : items){
		if(i != null && i.getType() != Material.AIR){
			r.addIngredient(i);
		}
	}
	
	r.removeIngredient(result);
	int ing = 0;
	
	RecipeShapeless fina = null;
	for(RecipeShapeless recipe : shapeless){
		if(recipe.matchLowest(r)){
			if(recipe.ingredientCount() >= ing){
				ing = recipe.ingredientCount();
			}else{
				continue;
			}
	
			if(recipe.hasPermission()){
				if(!p.hasPermission(recipe.getPermission())){
					continue;
				}
			}
			
			fina = recipe;
			
		}
	
	}
	
	if(fina != null){
		
		ItemStack old = result;
		
		WorkbenchCraftEvent workbenchEvent = new WorkbenchCraftEvent(ProRecipes.getAPI().getRecipe(RecipeType.SHAPELESS, shapeless.indexOf(fina)), p, inv, fina.getResult());
		ProRecipes.getPlugin().getServer().getPluginManager().callEvent(workbenchEvent);
				
		if(old != null){
			if(!old.isSimilar(fina.getResult())){
				p.updateInventory();
			}
		}
		//System.out.println("Milliseconds spent (handleDoubles): " + (mil - System.currentTimeMillis()));
		return true;
	}
	//System.out.println("Milliseconds spent (handleDoubles): " + (mil - System.currentTimeMillis()));
	return false;
	
}
 
源代码10 项目: LanguageUtils   文件: ItemEntryTest.java
@Test
public void testEquals() throws Exception {
    //Same Material
    ItemEntry equalEntry1 = new ItemEntry(Material.STONE);
    ItemEntry equalEntry2 = new ItemEntry(Material.STONE);

    assertThat(equalEntry1, is(equalEntry2));
    assertThat(equalEntry1.hashCode(), is(equalEntry2.hashCode()));

    //Same Material + metadata
    ItemEntry equalEntry3 = new ItemEntry(Material.STONE, 2);
    ItemEntry equalEntry4 = new ItemEntry(Material.STONE, 2);

    assertThat(equalEntry3, is(equalEntry4));
    assertThat(equalEntry3.hashCode(), is(equalEntry4.hashCode()));

    //Different Material
    ItemEntry diffEntry1 = new ItemEntry(Material.STONE);
    ItemEntry diffEntry2 = new ItemEntry(Material.ANVIL);

    assertThat(diffEntry1, not(diffEntry2));
    assertThat(diffEntry1.hashCode(), not(diffEntry2.hashCode()));

    //Different metadata
    ItemEntry diffEntry3 = new ItemEntry(Material.STONE, 4);
    ItemEntry diffEntry4 = new ItemEntry(Material.STONE, 7);

    assertThat(diffEntry3, not(diffEntry4));
    assertThat(diffEntry3.hashCode(), not(diffEntry4.hashCode()));

    //Different Material + metadata
    ItemEntry diffEntry5 = new ItemEntry(Material.STONE, 4);
    ItemEntry diffEntry6 = new ItemEntry(Material.SAND, 2);

    assertThat(diffEntry5, not(diffEntry6));
    assertThat(diffEntry5.hashCode(), not(diffEntry6.hashCode()));


    //HashMap Test
    Map<ItemEntry, EnumItem> testMap = new HashMap<ItemEntry, EnumItem>();

    testMap.put(equalEntry1, EnumItem.STONE);
    assertTrue(testMap.containsKey(equalEntry1));

    testMap.put(equalEntry3, EnumItem.POLISHED_GRANITE);
    assertTrue(testMap.containsKey(equalEntry4));

    assertFalse(testMap.containsKey(diffEntry2));
    assertFalse(testMap.containsKey(diffEntry3));
    assertFalse(testMap.containsKey(diffEntry6));
}
 
 方法所在类
 同类方法