当前位置: 首页>>代码示例>>Java>>正文


Java Material.WORKBENCH属性代码示例

本文整理汇总了Java中org.bukkit.Material.WORKBENCH属性的典型用法代码示例。如果您正苦于以下问题:Java Material.WORKBENCH属性的具体用法?Java Material.WORKBENCH怎么用?Java Material.WORKBENCH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.WORKBENCH属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openWorkbench

public InventoryView openWorkbench(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.WORKBENCH) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().displayGUIWorkbench(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    if (force) {
        getHandle().openContainer.checkReachable = false;
    }
    return getHandle().openContainer.getBukkitView();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:16,代码来源:CraftHumanEntity.java

示例2: cloneCraftingWindow

@EventHandler(priority = EventPriority.MONITOR)
public void cloneCraftingWindow(final PlayerInteractEvent event) {
    if(!AntiGrief.CraftProtect.enabled()) {
        return;
    }

    if(!event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getOpenInventory().getType() == InventoryType.CRAFTING /* nothing open */) {
        Block block = event.getClickedBlock();
        if(block != null && block.getType() == Material.WORKBENCH && !event.getPlayer().isSneaking()) {
            // create the window ourself
            event.setCancelled(true);
            event.getPlayer().openWorkbench(null, true); // doesn't check reachable
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:CraftingProtect.java

示例3: onDisable

public void onDisable()
{
	PluginDescriptionFile pdfFile = getDescription();
	Logger logger = getLogger();
	getServer().getScheduler().cancelTasks(this);
	getServer().resetRecipes();
	usingPlayers = new ArrayList<Player>();
	//Avoid WorkbenchShare glitch
	for(Player p : Bukkit.getOnlinePlayers())
	{
		if (p.hasMetadata("shared_workbench"))
		{
			Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
			
			if(workbench != null && workbench.getType() == Material.WORKBENCH)
			{
				if (workbench.hasMetadata("shared_players"))
					workbench.removeMetadata("shared_players", Survival.instance);
				else
					p.getOpenInventory().getTopInventory().clear();
				
				p.closeInventory();	
			}
			
			p.removeMetadata("shared_workbench", Survival.instance);
		}
	}
	
	logger.info(pdfFile.getName() + " has been disabled.");
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:30,代码来源:Survival.java

示例4: onInventoryClose

@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
	if (!(e.getPlayer() instanceof Player))
		return;
	final Player p = (Player) e.getPlayer();

	if (!p.hasMetadata("shared_workbench"))
		return;
	if (e.getInventory().getType() == InventoryType.WORKBENCH)
	{
		// Workaround to get the accessed WorkBench
		final Block workbench = p.getTargetBlock((Set<Material>) null, 8);

		if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
		{
			if (p.getOpenInventory().getTopInventory() != null)
				p.getOpenInventory().getTopInventory().clear();
			p.removeMetadata("shared_workbench", Survival.instance);
			
			return;
		}

		@SuppressWarnings("unchecked")
		List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
		
		list.remove(p.getUniqueId());
		
		if (list.isEmpty())
			workbench.removeMetadata("shared_players", Survival.instance);
		else
		{
			e.getInventory().clear();
			workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:37,代码来源:WorkbenchShare.java

示例5: onPlayerQuit

@EventHandler
public void onPlayerQuit(PlayerQuitEvent e)
{
	if (!(e.getPlayer() instanceof Player))
		return;
	final Player p = (Player) e.getPlayer();

	if (!p.hasMetadata("shared_workbench"))
		return;
	
	Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
	
	if (workbench != null && workbench.hasMetadata("shared_players") && workbench.getType() == Material.WORKBENCH)
	{
		@SuppressWarnings("unchecked")
		List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();

		list.remove(p.getUniqueId());
		
		if (list.isEmpty())
			workbench.removeMetadata("shared_players", Survival.instance);
		else
			workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
	}
	
	p.removeMetadata("shared_workbench", Survival.instance);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:27,代码来源:WorkbenchShare.java

示例6: isInteractiveBlock

/**
 * checks if this block would give a reaction if you click on it without
 * shifting, e.g. opening a chest or switching a lever
 */
public static boolean isInteractiveBlock(Block b) {
	if (b == null || b.getState() == null) {
		return false;
	}
	if (b.getType() == Material.WORKBENCH || b.getType() == Material.ENCHANTMENT_TABLE || b.getType() == Material.ANVIL || b.getType() == Material.BREWING_STAND || b.getState() instanceof InventoryHolder || b.getState() instanceof NoteBlock) {
		return true;
	}
	if (b.getState().getData() instanceof Button || b.getState().getData() instanceof Lever || b.getState().getData() instanceof Door || b.getState().getData() instanceof TrapDoor || b.getState().getData() instanceof Gate || b.getState().getData() instanceof Comparator) {
		if (b.getType() != Material.IRON_DOOR && b.getType() != Material.IRON_DOOR_BLOCK && b.getType() != Material.IRON_TRAPDOOR) {
			return true;
		}
	}
	return false;
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:18,代码来源:HitboxUtils.java

示例7: onCraftItem

/**
 * Accept only one bench crafting
 *
 * @param event Event
 */
@EventHandler
public void onCraftItem(CraftItemEvent event)
{
    this.onCraftItem(event.getRecipe(), event.getInventory(), event.getWhoClicked());

    if (event.getRecipe().getResult().getType() == Material.WORKBENCH && !this.crafters.contains(event.getWhoClicked().getUniqueId()))
        this.crafters.add(event.getWhoClicked().getUniqueId());
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:13,代码来源:OneWorkbenchModule.java

示例8: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    final TOAUser u = TOA.getPlayer(e.getPlayer());

    if (e.getItem() != null) {
        Material m = e.getItem().getType();
        if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
        Ability.useAbility(u, e.getItem().getType());
        e.setCancelled(true);
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:29,代码来源:GameEvents.java

示例9: onPlayerInteract

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent e)
{
	if(e.isCancelled()) return;
	final Player p = e.getPlayer();
	
	if(e.getClickedBlock() == null)
		return;
	
	final Block block = e.getClickedBlock();
	
	if(e.getAction() != Action.RIGHT_CLICK_BLOCK)
		return;
	
	if(block.getType() == Material.WORKBENCH)
	{
		Bukkit.getServer().getScheduler().runTask(Survival.instance, new Runnable()
		{
			@Override
			public void run()
			{
				if (!p.isOnline())
					return;
				
				if (!block.hasMetadata("shared_players"))
					block.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, new ArrayList<UUID>()));
				
				@SuppressWarnings("unchecked")
				final List<UUID> list = (block.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>) block.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
				
				final Inventory open = p.getOpenInventory().getTopInventory();
				
				if (open == null || open.getType() != InventoryType.WORKBENCH)
					return;

				// Workaround to get the accessed WorkBench
				final Block workbench = p.getTargetBlock((Set<Material>) null, 8);
				
				if (workbench == null || workbench.getType() != Material.WORKBENCH)
				{
					// Close Inventory if player managed to access the workbench without actually use one.
					p.closeInventory();
					return;
				}

				list.add(p.getUniqueId());
				p.setMetadata("shared_workbench", new FixedMetadataValue(Survival.instance, block));

				Bukkit.getServer().getScheduler().runTaskLater(Survival.instance, new Runnable()
				{
					@Override
					public void run()
					{
						if (list.isEmpty())
							return;
						Player first = Bukkit.getPlayer(list.get(0));
						Inventory pInv = first.getOpenInventory().getTopInventory();
						if (pInv == null || pInv.getType() != InventoryType.WORKBENCH)
							return;
						open.setContents(pInv.getContents());
						Bukkit.getServer().getScheduler().runTaskLater(Survival.instance, new Runnable()
						{
							@SuppressWarnings("deprecation")
							@Override
							public void run()
							{
								p.updateInventory();
							}
						}, 1);
					}
				}, 1);
			}
		});
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:75,代码来源:WorkbenchShare.java

示例10: onBreakWorkbench

@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakWorkbench(BlockBreakEvent e)
{
	if(e.isCancelled()) return;
	Block workbench = e.getBlock();

	if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
		return;
	
	@SuppressWarnings("unchecked")
	List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
	
	Iterator<UUID> iterator = list.iterator();
	
	Inventory sharedInventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
	
	while (iterator.hasNext())
	{
		UUID next = iterator.next();
		
		iterator.remove();
		
		final Player idPlayer = Bukkit.getPlayer(next);
		
		if (idPlayer != null)
		{
			idPlayer.removeMetadata("shared_inv", Survival.instance);
			
			if(idPlayer.isOnline())
			{
				final Inventory open = idPlayer.getOpenInventory().getTopInventory();
				
				if (open != null && open.getType() == InventoryType.WORKBENCH)
				{
					sharedInventory.setContents(open.getContents());
					open.clear();
					idPlayer.closeInventory();
				}
			}
		}
	}
	
	for(int i = 1; i < sharedInventory.getSize(); i++)
	{
		ItemStack item = sharedInventory.getItem(i);
		if(item != null)
			workbench.getWorld().dropItem(workbench.getLocation(), item);
	}
	
	workbench.removeMetadata("shared_players", Survival.instance);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:51,代码来源:WorkbenchShare.java

示例11: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    PAUser u = PAServer.getUser(e.getPlayer());

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getItem() == null) return;
        e.setCancelled(true);
        if (Cosmetic.useCosmetic(u, e.getItem().getType())) return;

        switch (e.getItem().getType()) {
            case NETHER_STAR:
                e.setCancelled(true);
                LobbyMenu.openMenu(u, LobbyMenu.MenuType.SERVERS);
                break;
            case REDSTONE:
                e.setCancelled(true);
                u.sendMessage(PAData.LOBBY.getPrefix() + "&cNo estamos listos aún");
                //LobbyMenu.openMenu(u, LobbyMenu.MenuType.COSMETICOS);
                break;
            case WOOD_AXE:
                e.setCancelled(true);
                u.sendToServer("cons");
                break;
        }

        if (e.getClickedBlock() == null) return;
        if (e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE) {
            e.setCancelled(true);
            u.sendMessage(PAData.LOBBY.getPrefix() + "&cActualmente estamos trabajando en esto, disculpen las molestias");
        }
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:50,代码来源:PlayerEvents.java

示例12: BlockWorkbench

public BlockWorkbench() {
    super( Material.WORKBENCH );
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:3,代码来源:BlockWorkbench.java

示例13: ItemSpecWorkbench

public ItemSpecWorkbench() {
    super( Material.WORKBENCH );
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:3,代码来源:ItemSpecWorkbench.java


注:本文中的org.bukkit.Material.WORKBENCH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。