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


Java FixedMetadataValue类代码示例

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


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

示例1: shoot

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
public void shoot(Player player){
    setAttackTimer(getAttackTimer() + System.currentTimeMillis() - getLastAttackTimer());
    setLastAttackTimer(System.currentTimeMillis());
    if(getAttackTimer() < getShootCooldown()) return;

    /*if (hasBullets()) {
        System.out.println("Tiene balas: " + Integer.parseInt(lore.get(lore.size() - 1).split(" ")[1]));
        youShotM8();
    }*/
    
    Snowball snowball = player.getWorld().spawn(player.getEyeLocation(), Snowball.class);
    snowball.setVelocity(player.getLocation().getDirection().multiply(distance()));
    snowball.setShooter(player);
    snowball.setMetadata("twd", new FixedMetadataValue(WCTWD.getInstance(), "weapon_" + getId()));

    //
    player.playSound(player.getLocation(), sound, 1, 1);
    particle.display(particleData, 0, 0, 0, 1, 3, player.getLocation(), 20);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:20,代码来源:Weapon.java

示例2: GameSign

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
public GameSign(Hub hub, AbstractGame game, String map, ChatColor color, String template, RestrictedVersion restrictedVersion, Sign sign)
{
    this.hub = hub;
    this.game = game;
    this.map = map;
    this.color = color;
    this.template = template;
    this.restrictedVersion = restrictedVersion;
    this.sign = sign;

    this.sign.setMetadata("game", new FixedMetadataValue(hub, game.getCodeName()));
    this.sign.setMetadata("map", new FixedMetadataValue(hub, map));

    hub.getScheduledExecutorService().scheduleAtFixedRate(this::scrollMapName, 500, 500, TimeUnit.MILLISECONDS);

    this.updateTask = hub.getServer().getScheduler().runTaskTimerAsynchronously(hub, this::update, 20L, 20L);
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:18,代码来源:GameSign.java

示例3: onEntityDamage

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
/**
 * Cancel damages if the game doesn't activate them
 * Also set last damage cause of the damaged player
 *
 * @param event Event
 */
@EventHandler
public void onEntityDamage(EntityDamageEvent event)
{
    if (event.getEntity() instanceof Player)
    {
        if (!this.game.isDamagesActivated())
        {
            event.setCancelled(true);
            return;
        }

        if (event.getCause() != EntityDamageEvent.DamageCause.ENTITY_ATTACK && event.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION)
        {
            while (event.getEntity().hasMetadata("lastDamager"))
                event.getEntity().removeMetadata("lastDamager", this.game.getPlugin());

            event.getEntity().setMetadata("lastDamager", new FixedMetadataValue(this.game.getPlugin(), event.getCause()));
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:27,代码来源:GameListener.java

示例4: onProjectileLaunch

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
/**
 * Launch 2 more arrows when one is launched
 *
 * @param event Event
 */
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event)
{
    if (event.getEntity().getType() != EntityType.ARROW || !(event.getEntity().getShooter() instanceof Player) || event.getEntity().hasMetadata("TAM"))
        return;

    final Vector velocity = event.getEntity().getVelocity();

    for(int i = 0; i < 2; i++)
    {
        this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
        {
            EntityArrow entityArrow = new EntityArrow(((CraftWorld)event.getEntity().getWorld()).getHandle(), ((CraftLivingEntity)event.getEntity().getShooter()).getHandle(), 1F);
            entityArrow.shoot(((CraftLivingEntity)event.getEntity().getShooter()).getHandle().pitch, ((CraftLivingEntity)event.getEntity().getShooter()).getHandle().yaw, 0.0F, 3.0F, 1.0F);
            entityArrow.getBukkitEntity().setMetadata("TAM", new FixedMetadataValue(this.plugin, true));
            entityArrow.getBukkitEntity().setVelocity(velocity);
            ((CraftWorld)event.getEntity().getWorld()).getHandle().addEntity(entityArrow);
        }, 5L * (i + 1));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:ThreeArrowModule.java

示例5: handleInteract

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@EventHandler
public void handleInteract(@Nonnull PlayerInteractEvent event) {
    if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
        if (event.getClickedBlock().getState() instanceof Sign) {
            Sign sign = (Sign) event.getClickedBlock().getState();
            if (sign.hasMetadata("UpdateCooldown")) {
                long cooldown = sign.getMetadata("UpdateCooldown").get(0).asLong();
                if (cooldown > System.currentTimeMillis() - 1 * 1000) {
                    return;
                }
            }
            sign.update();
            sign.setMetadata("UpdateCooldown", new FixedMetadataValue(voxelGamesLib, System.currentTimeMillis()));
        }
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:17,代码来源:SignPlaceholders.java

示例6: onPlayerMoveEvent

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event){
	Player p = event.getPlayer();
	//p.sendMessage(""+p.getFallDistance());
	//p.sendMessage(""+p.getVelocity().getY());
	if(playerCanFall(p)){			
		//fix NCP false alarm
		//Utility.ncpFix(p);

		p.setGliding(true);
		FixedMetadataValue m = new FixedMetadataValue(plugin, null);
		p.setMetadata("falling", m);
	}else if(p.hasMetadata("falling")){
		p.removeMetadata("falling", plugin);
	}
}
 
开发者ID:4a2e532e,项目名称:RealisticSwimming,代码行数:17,代码来源:RFallListener.java

示例7: onInteract

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent e) {
	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getClickedBlock().getType() == Material.CAULDRON) {
			if (e.getClickedBlock().getLocation().add(0, -1, 0).getBlock().getType() == Material.DIAMOND_BLOCK) {
				Item item = e.getPlayer().getWorld().dropItem(e.getClickedBlock().getLocation().add(0.5, 2, 0.5), e.getPlayer().getEquipment().getItemInMainHand());
				item.setMetadata("item-owner", new FixedMetadataValue(NationZ.plugin, e.getPlayer().getUniqueId().toString()));
				item.setVelocity(new Vector(0, 0, 0));
				item.setCustomName(item.getName());
				item.setCustomNameVisible(true);
				e.getPlayer().getEquipment().setItemInMainHand(null);
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:crazyhorse961,项目名称:NationZ,代码行数:17,代码来源:JobEnchanter.java

示例8: onEntityExplode

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@EventHandler
    public void onEntityExplode(EntityExplodeEvent event) {
        if (event.getEntity() != null) {
            if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
                for (Block block : event.blockList()) {
                    if (block.getType() == Material.TNT && getWhoPlaced(event.getEntity()) != null) {
                        Location location = block.getLocation();
                        tntPlaced.put(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), getWhoPlaced(event.getEntity()));
                    }
                }

                for (Entity entity : event.getEntity().getNearbyEntities(8, 8, 8)) {
//                    F.debug("Found tnt");
                    if (entity instanceof TNTPrimed) {
                        UUID playerUUID = getWhoPlaced(event.getEntity());
                        if(playerUUID != null) {
                            Dispenser dispenser;
//                            F.debug("found placer: " + Bukkit.getServer().getPlayer(playerUUID));
                            entity.setMetadata("source", new FixedMetadataValue(GamePlate.getInstance(), playerUUID));
                        }
                    }
                }
            }
        }
    }
 
开发者ID:Minehut,项目名称:GamePlate,代码行数:26,代码来源:TntTracker.java

示例9: onCrossBoundary

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
	if (!WorldGuardUtils.hasBypass(player))
	{
		if (!player.hasMetadata("WGEFP-TPOEF"))
		{
			com.sk89q.worldedit.Location location = toSet.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.TELEPORT_ON_ENTRY);
			if (location != null)
			{
				player.setMetadata("WGEFP-TPOEF", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
				player.teleport(BukkitUtil.toLocation(location));
			}
		}
	}
	
	return true;
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:20,代码来源:TeleportOnEntryFlag.java

示例10: onCrossBoundary

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
	if (!WorldGuardUtils.hasBypass(player))
	{
		if (!player.hasMetadata("WGEFP-TPOEF"))
		{
			for (ProtectedRegion exitd : exited)
			{
				com.sk89q.worldedit.Location location = exitd.getFlag(FlagUtils.TELEPORT_ON_EXIT);
				if (location != null)
				{
					player.setMetadata("WGEFP-TPOEF", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
					player.teleport(BukkitUtil.toLocation(location));
					
					break;
				}
			}
		}
	}
	
	return true;
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:25,代码来源:TeleportOnExitFlag.java

示例11: onEntitySpawn

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    LivingEntity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG)
    {
        entity.setMetadata(this.ALLOW_TARGET_TAG, new FixedMetadataValue(GPFlags.instance, new Boolean(true)));
        return;
    }
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:19,代码来源:FlagDef_NoMonsterSpawns.java

示例12: showInFrame

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@Override
public void showInFrame(Player player, int entityId, String debugInfo) {
	if (!isViewing(player)) {
		return;
	}
	//Create the ItemStack with the player's map ID
	ItemStack itemStack = new ItemStack(Material.MAP, 1, getMapId(player));
	if (debugInfo != null) {
		//Add the debug info to the display
		ItemMeta itemMeta = itemStack.getItemMeta();
		itemMeta.setDisplayName(debugInfo);
		itemStack.setItemMeta(itemMeta);
	}

	ItemFrame itemFrame = MapManagerPlugin.getItemFrameById(player.getWorld(), entityId);
	if (itemFrame != null) {
		//Add a reference to this MapWrapper (can be used in MapWrapper#getWrapperForId)
		itemFrame.removeMetadata("MAP_WRAPPER_REF", MapManagerPlugin.instance);
		itemFrame.setMetadata("MAP_WRAPPER_REF", new FixedMetadataValue(MapManagerPlugin.instance, DefaultMapWrapper.this));
	}

	sendItemFramePacket(player, entityId, itemStack);
}
 
开发者ID:InventivetalentDev,项目名称:MapManager,代码行数:24,代码来源:DefaultMapWrapper.java

示例13: change

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (object.getSingle(e) instanceof Metadatable) {
		Metadatable metadata = (Metadatable)object.getSingle(e);
		if (mode == ChangeMode.SET) {
			if (metadata.hasMetadata(string.getSingle(e))) {
				metadata.removeMetadata(string.getSingle(e), Skellett.plugin);
			}
			metadata.setMetadata(string.getSingle(e), (MetadataValue)new FixedMetadataValue(Skellett.plugin, (Object)(delta[0])));
		} else if (mode == ChangeMode.RESET || mode == ChangeMode.DELETE) {
			if (metadata.hasMetadata(string.getSingle(e))) {
				metadata.removeMetadata(string.getSingle(e), Skellett.plugin);
			}
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:17,代码来源:ExprMetadata.java

示例14: pm

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@Command(aliases = {"msg", "message", "pm", "privatemessage", "whisper", "tell"}, desc = "Send a private message to a player.", usage = "<player> <message>", min = 2)
public static void pm(final CommandContext cmd, CommandSender sender) throws CommandException {
    if (!(sender instanceof Player)) throw new CommandException(ChatConstant.ERROR_PLAYER_COMMAND.getMessage(Locale.getDefault().toString()));

    Player target = Bukkit.getPlayer(cmd.getString(0), sender);
    if (target == null) {
        throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_FOUND.getMessage(((Player) sender).getLocale()));
    }
    if (Settings.getSettingByName("PrivateMessages") == null || Settings.getSettingByName("PrivateMessages").getValueByPlayer(target).getValue().equalsIgnoreCase("all")) {
        target.sendMessage(ChatColor.GRAY + "(From " + TeamUtils.getTeamColorByPlayer((Player) sender) + ((Player) sender).getDisplayName() + ChatColor.GRAY + "): " + ChatColor.RESET + cmd.getJoinedStrings(1));
        sender.sendMessage(ChatColor.GRAY + "(To " + TeamUtils.getTeamColorByPlayer(target) + target.getDisplayName() + ChatColor.GRAY + "): " + ChatColor.RESET + cmd.getJoinedStrings(1));
        target.setMetadata("reply", new FixedMetadataValue(Cardinal.getInstance(), sender));
    } else {
        sender.sendMessage(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_DISABLED_PMS, target.getDisplayName()).getMessage(((Player) sender).getLocale()));
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:17,代码来源:PrivateMessageCommands.java

示例15: reply

import org.bukkit.metadata.FixedMetadataValue; //导入依赖的package包/类
@Command(aliases = {"reply", "r"}, desc = "Reply to a private message", min = 1)
public static void reply(final CommandContext cmd, CommandSender sender) throws CommandException {
    if (!(sender instanceof Player)) {
        throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_COMMAND).getMessage(ChatUtils.getLocale(sender)));
    }
    if (!((Player) sender).hasMetadata("reply")) {
        throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_NO_MESSAGES).getMessage(ChatUtils.getLocale(sender)));
    }
    Player target = (Player) ((Player) sender).getMetadata("reply").get(0).value();
    if (target == null) {
        throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_FOUND.getMessage(((Player) sender).getLocale()));
    }
    if (Settings.getSettingByName("PrivateMessages") == null || Settings.getSettingByName("PrivateMessages").getValueByPlayer(target).getValue().equalsIgnoreCase("all")) {
        target.sendMessage(ChatColor.GRAY + "(From " + TeamUtils.getTeamColorByPlayer((Player) sender) + ((Player) sender).getDisplayName() + ChatColor.GRAY + "): " + ChatColor.RESET + cmd.getJoinedStrings(0));
        sender.sendMessage(ChatColor.GRAY + "(To " + TeamUtils.getTeamColorByPlayer(target) + target.getDisplayName() + ChatColor.GRAY + "): " + ChatColor.RESET + cmd.getJoinedStrings(0));
        target.setMetadata("reply", new FixedMetadataValue(Cardinal.getInstance(), sender));
    } else {
        sender.sendMessage(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_DISABLED_PMS, target.getDisplayName()).getMessage(((Player) sender).getLocale()));
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:21,代码来源:PrivateMessageCommands.java


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