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


Java Jukebox类代码示例

本文整理汇总了Java中org.bukkit.block.Jukebox的典型用法代码示例。如果您正苦于以下问题:Java Jukebox类的具体用法?Java Jukebox怎么用?Java Jukebox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: change

import org.bukkit.block.Jukebox; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (mode == ChangeMode.SET) {
		if (block != null) {
			if (block.getSingle(e) instanceof Jukebox) {
				String type = (String)delta[0];
				try {
					Material material = Material.valueOf(type.replace("\"", "").trim().replace(" ", "_").toUpperCase());
					((Jukebox)block.getSingle(e)).setPlaying(material);
				} catch (IllegalArgumentException error) {
					Bukkit.getConsoleSender().sendMessage(Skellett.cc(Skellett.prefix + "&cUnknown material type " + type));
					return;
				}
			}
		}
	} else if (mode == ChangeMode.RESET) {
		if (((Jukebox)block.getSingle(e)).isPlaying()) {
			((Jukebox)block.getSingle(e)).eject();
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:22,代码来源:ExprJukeboxMusic.java

示例2: execute

import org.bukkit.block.Jukebox; //导入依赖的package包/类
@Override
protected void execute(Event e) {
	if (block != null) {
		BlockState state = block.getSingle(e).getState();
		if (state instanceof Jukebox) {
			Jukebox jukebox = (Jukebox) state;
			jukebox.eject();
			jukebox.update();
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:12,代码来源:EffJukeboxEject.java

示例3: get

import org.bukkit.block.Jukebox; //导入依赖的package包/类
@Override
@Nullable
protected Material[] get(Event e) {
	if (block != null) {
		if (block.getSingle(e) instanceof Jukebox) {
			return new Material[]{((Jukebox)block.getSingle(e)).getPlaying()};
		}
	}
	return null;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:ExprJukeboxMusic.java

示例4: check

import org.bukkit.block.Jukebox; //导入依赖的package包/类
public boolean check(Event e) {
	if (block.getSingle(e) instanceof Jukebox) {
		if (((Jukebox)block.getSingle(e)).isPlaying()) {
			return isNegated();
		} else {
			return !isNegated();
		}
	}
	return false;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:CondJukeboxIsPlaying.java

示例5: serializeState

import org.bukkit.block.Jukebox; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static Optional<String> serializeState(BlockState state) {
    YamlConfiguration yaml = new YamlConfiguration();

    // http://minecraft.gamepedia.com/Block_entity was used as a reference for this method

    if (state instanceof InventoryHolder) {
        yaml.set(INVENTORY_KEY, InventoryHelper.serializeInventory(((InventoryHolder) state).getInventory()));
    }

    if (state instanceof Sign) {
        yaml.set(SIGN_LINES_KEY, Arrays.asList(((Sign) state).getLines()));
    } else if (Support.BANNER && state instanceof Banner) {
        yaml.set(BANNER_BASE_COLOR_KEY, ((Banner) state).getBaseColor().name());
        ConfigurationSection patternSection = yaml.createSection(BANNER_PATTERNS_KEY);
        List<Pattern> patterns = ((Banner) state).getPatterns();
        for (int i = 0; i < patterns.size(); i++) {
            ConfigurationSection subSection = patternSection.createSection("" + i);
            subSection.set(BANNER_PATTERN_COLOR_KEY, patterns.get(i).getColor().name());
            subSection.set(BANNER_PATTERN_TYPE_KEY, patterns.get(i).getPattern().name());
        }
    } else if (state instanceof CreatureSpawner) {
        yaml.set(SPAWNER_TYPE_KEY, ((CreatureSpawner) state).getSpawnedType().name());
        yaml.set(SPAWNER_DELAY_KEY, ((CreatureSpawner) state).getDelay());
    } else if (state instanceof NoteBlock) {
        yaml.set(NOTE_OCTAVE_KEY, ((NoteBlock) state).getNote().getOctave());
        yaml.set(NOTE_TONE_KEY, ((NoteBlock) state).getNote().getTone().name());
    } else if (state instanceof Jukebox) {
        if (((Jukebox) state).isPlaying()) {
            yaml.set(JUKEBOX_DISC_KEY, ((Jukebox) state).getPlaying());
        }
    } else if (state instanceof Skull) {
        yaml.set(SKULL_OWNER_KEY, ((Skull) state).getOwner());
        yaml.set(SKULL_ROTATION_KEY, ((Skull) state).getRotation().name());
    } else if (state instanceof CommandBlock) {
        yaml.set(COMMAND_NAME_KEY, ((CommandBlock) state).getName());
        yaml.set(COMMAND_CMD_KEY, ((CommandBlock) state).getCommand());
    } else if (state instanceof FlowerPot) {
        yaml.set(FLOWER_TYPE_KEY, ((FlowerPot) state).getContents().getItemType().name());
        yaml.set(FLOWER_DATA_KEY, ((FlowerPot) state).getContents().getData());
    }

    if (yaml.getKeys(false).size() > 0) {
        return Optional.of(yaml.saveToString());
    }
    return Optional.absent();
}
 
开发者ID:caseif,项目名称:Steel,代码行数:48,代码来源:BlockStateSerializer.java

示例6: playMusic

import org.bukkit.block.Jukebox; //导入依赖的package包/类
private void playMusic(Player p) {
    p.getLocation().getBlock().setType(Material.JUKEBOX);
    final Jukebox jb = (Jukebox) p.getLocation().getBlock().getState();
    jb.setPlaying(Material.RECORD_11);

    MiscUtils.shootFirework(jb.getLocation().add(0.5,0,0.5), p.getWorld().getName());

    ScheduleUtils.scheduleTask(500, new Runnable() {
        @Override
        public void run() {
            jb.setPlaying(null);
            jb.getBlock().setType(Material.AIR);
        }
    });
}
 
开发者ID:Cooltimmetje,项目名称:PretparkCore,代码行数:16,代码来源:GadgetTriggers.java

示例7: enable

import org.bukkit.block.Jukebox; //导入依赖的package包/类
public void enable() {
	Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
		@SuppressWarnings("deprecation")
		@Override
		public void run() {
			World w = Bukkit.getWorld("Survival");
			Jukebox a = (Jukebox) w.getBlockAt(64, 70, 198).getState();
			ArrayList<Material> discs = new ArrayList<Material>();
			discs.add(Material.getMaterial(2257));
			discs.add(Material.getMaterial(2258));
			discs.add(Material.getMaterial(2260));
			discs.add(Material.getMaterial(2261));
			discs.add(Material.getMaterial(2263));
			discs.add(Material.getMaterial(2264));
			discs.add(Material.getMaterial(2267));
			Block db = w.getBlockAt(a.getBlock().getLocation().clone().add(0,-1,0));
			int type = db.getData();
			type++;
			if (type > 6) {
				type = 0;
			}
			a.setPlaying(discs.get(type));
			db.setData((byte) type);
			//				
		}
	}, 20*5, 20*60*3);
	log("Enabled");
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:29,代码来源:SpawnMusic.java

示例8: onBlockBreak

import org.bukkit.block.Jukebox; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
    if (event.getBlock().getType() == AIR)
    {
        return; // breaking air !? -> no logging
    }
    if (!this.isActive(PlayerBlockBreak.class, event.getBlock().getWorld()))
    {
        return;
    }
    BlockState blockState = event.getBlock().getState();
    PlayerBlockBreak action;
    if (blockState instanceof NoteBlock)
    {
        action = this.newAction(PlayerNoteBlockBreak.class);
        ((PlayerNoteBlockBreak)action).setNote(((NoteBlock)blockState).getNote());
    }
    else if (blockState instanceof Sign)
    {
        action = this.newAction(PlayerSignBreak.class);
        ((PlayerSignBreak)action).setLines(((Sign)blockState).getLines());
    }
    else if (blockState instanceof Jukebox && ((Jukebox)blockState).getPlaying() != null)
    {
        action = this.newAction(PlayerJukeboxBreak.class);
        ((PlayerJukeboxBreak)action).setDisc(((Jukebox)blockState).getPlaying());
    }
    else if (blockState instanceof InventoryHolder)
    {
        action = this.newAction(PlayerContainerBreak.class, event.getBlock().getWorld());
        if (action == null)
        {
            action = this.newAction(PlayerBlockBreak.class);
        }
        else
        {
            ((PlayerContainerBreak)action).setContents(((InventoryHolder)blockState).getInventory().getContents());
        }
        // TODO item drops
        // itemDrop.logDropsFromChest((InventoryHolder)blockState,location,event.getPlayer());
    }
    else
    {
        action = this.newAction(PlayerBlockBreak.class);
        blockState = adjustBlockForDoubleBlocks(blockState); // WOOD_DOOR IRON_DOOR OR BED_BLOCK
    }
    action.setPlayer(event.getPlayer());
    action.setLocation(event.getBlock().getLocation());
    action.setOldBlock(blockState);
    action.setNewBlock(AIR);
    this.logAction(action);

    if (blockState.getType() == OBSIDIAN) // portal?
    {
        // TODO better & complete
        Block block = blockState.getBlock();
        for (BlockFace face : BLOCK_FACES)
        {
            if (block.getRelative(face).getType() == PORTAL)
            {
                Block portal = block.getRelative(face);
                PlayerBlockBreak pAction = this.newAction(PlayerBlockBreak.class);
                pAction.setPlayer(event.getPlayer());
                pAction.setLocation(portal.getLocation());
                pAction.setOldBlock(portal.getState());
                pAction.setNewBlock(AIR);
                pAction.reference = this.reference(action);
                this.logAction(pAction);
                break;
            }
        }
    }
    // TODO attached & falling
    ListenerBlock.logAttachedBlocks(this, module.getCore().getEventManager(), event.getBlock(), action);
    ListenerBlock.logFallingBlocks(this, module.getCore().getEventManager(), event.getBlock(), action);
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:78,代码来源:ListenerPlayerBlock.java


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