• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Player类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getTarget

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
public Object getTarget(TargetType type, Player player, int range) {
	switch (type) {
	case ENTITY:
		return SpongeTargetUtils.getTargetEntity(player, range);
	case ENTITY_AREA:
		return SpongeTargetUtils.getNearbyEntities(player, range);
	case LIVING:
		return SpongeTargetUtils.getTargetLiving(player, range);
	case LIVING_AREA:
		return SpongeTargetUtils.getNearbyLivings(player, range);
	case MONSTER:
		return SpongeTargetUtils.getTargetMonster(player, range);
	case MONSTER_AREA:
		return SpongeTargetUtils.getNearbyMonsters(player, range);
	case PLAYER:
		return SpongeTargetUtils.getTargetPlayer(player, range);
	case PLAYER_AREA:
		return SpongeTargetUtils.getNearbyPlayers(player, range);
	case SELF:
		return SpongeTargetUtils.getTargetEntity(player, range);
	case BLOCK:
		return SpongeTargetUtils.getTargetBlock(player, range);
	default:
		return null;
	}
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:27,代码来源:SpongeSpellContext.java


示例2: getTarget

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
protected static <T extends Entity> T getTarget(Player player, int range, Collection<T> entities) {
	BlockRay iterator = BlockRay.from(player).blockLimit(range).build();
	while (iterator.hasNext()) {
		BlockRayHit block = iterator.next();
		for (T entity : entities) {
			int accuracy = 2;
			for (int offX = -accuracy; offX < accuracy; offX++) {
				for (int offY = -accuracy; offY < accuracy; offY++) {
					for (int offZ = -accuracy; offZ < accuracy; offZ++) {
						if (entity.getLocation().getBlockPosition().add(offX, offY, offZ)
								.equals(block.getLocation().getBlockPosition())) {
							return entity;
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:21,代码来源:SpongeTargetUtils.java


示例3: getNearbyEntities

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
protected static Collection<Entity> getNearbyEntities(Player player, int radius) {
	final Player p = player;
	final Location loc = player.getLocation();
	final int range = radius;

	Collection<Entity> entities = player.getWorld().getEntities(new Predicate<Entity>() {
		@Override
		public boolean apply(Entity en) {
			if (en != p && en.getLocation().getBlockPosition().distance(loc.getBlockPosition()) < range) {
				return true;
			}
			return false;
		}
	});

	return entities;
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:18,代码来源:SpongeTargetUtils.java


示例4: commandMana

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Directive(names = { "mana" }, description = "Displays your mana", inGameOnly = true)
public static CommandResult commandMana(CommandSource src, CommandContext context) {
	User user = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());

	TextBuilder builder = Texts.builder("Mana " + user.getMana() + " / " + user.getMaximumMana() + ": [").color(
			TextColors.GRAY);
	int percent = (int) (((float) user.getMana() / (float) user.getMaximumMana()) * 10);
	TextBuilder tempBuilder = Texts.builder();
	tempBuilder.color(TextColors.AQUA);
	for (int i = 1; i <= 10; i++) {
		tempBuilder.append(Texts.of("="));
		if (i == percent) {
			builder.append(tempBuilder.build());
			tempBuilder = Texts.builder();
		}
	}
	tempBuilder.color(TextColors.DARK_GRAY);
	builder.append(tempBuilder.build());
	builder.append(Texts.of("]")).color(TextColors.GRAY);

	src.sendMessage(builder.build());
	return CommandResult.success();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:24,代码来源:UserCommand.java


示例5: commandProgress

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Directive(names = { "progress" }, description = "Displays your progress", inGameOnly = true)
public static CommandResult commandProgress(CommandSource src, CommandContext context) {
	User user = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());

	TextBuilder builder = Texts.builder(
			"Progress " + user.getUserData().getLevelProgress() + " / " + user.getRequiredLevelProgress() + ": [")
			.color(TextColors.GRAY);
	float percent = ((float) user.getUserData().getLevelProgress() / (float) user.getRequiredLevelProgress()) * 10;
	TextBuilder tempBuilder = Texts.builder();
	tempBuilder.color(TextColors.GREEN);
	for (int i = 0; i < 10; i++) {
		tempBuilder.append(Texts.of("="));
		if (i == (int)percent) {
			builder.append(tempBuilder.build());
			tempBuilder = Texts.builder();
		}
	}
	tempBuilder.color(TextColors.DARK_GRAY);
	builder.append(tempBuilder.build());
	builder.append(Texts.of("] Level " + user.getUserData().getLevel())).color(TextColors.GRAY);

	src.sendMessage(builder.build());
	return CommandResult.success();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:25,代码来源:UserCommand.java


示例6: commandManaRestore

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Directive(names = { "mana.restore" }, description = "Restores your mana", inGameOnly = true, argumentLabels = { "target" }, arguments = { ArgumentType.OPTIONAL_STRING })
public static CommandResult commandManaRestore(CommandSource src, CommandContext context) {
	User target = null;
	if (!context.getOne("target").isPresent()) {
		target = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());
	} else {
		Player player = null;
		if ((player = ZephyrPlugin.getGame().getServer().getPlayer(context.<String> getOne("target").get()).get()) != null) {
			target = Zephyr.getUserManager().getUser(player.getUniqueId());
		} else {
			target = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());
		}
	}

	target.setMana(target.getMaximumMana());
	target.<Player> getPlayer().sendMessage(Texts.builder("Mana restored!").color(TextColors.AQUA).build());

	return CommandResult.success();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:20,代码来源:UserCommand.java


示例7: commandAliasCast

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Directive(names = {"c"}, description = "Cast an alias", inGameOnly = true, argumentLabels = {"spell", "args"}, arguments = {ArgumentType.OPTIONAL_STRING, ArgumentType.OPTIONAL_REMAINING})
public static CommandResult commandAliasCast(CommandSource src, CommandContext context) {
	User user = Zephyr.getUserManager().getUser(((Player)src).getUniqueId());
	SpellManager manager = Zephyr.getSpellManager();
	String key = context.<String>getOne("spell").get();
	if (context.getOne("spell").isPresent()) {
		if (user.getAliases().containsKey(key)) {
			Spell spell = manager.getSpell(user.getAliases().get(key));
			Optional<String> options = context.<String>getOne("args");
			manager.cast(spell, new SpongeSpellContext(spell, user, options.isPresent() ? options.get().split(" ") : new String[0]));
		} else {
			user.sendMessage("That alias was not found. Set it with /alias <key> <spell>");
		}
		return CommandResult.success();
	} else {
		if (user.isCasting()) {
			user.setCasting(null, null);
		} else {
			user.sendMessage("Usage: /cast <spell> [args...]");
		}
		return CommandResult.success();
	}
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:24,代码来源:UserCommand.java


示例8: onCast

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Directive(names = { "cast" }, argumentLabels = {"spell", "args"}, arguments = {ArgumentType.OPTIONAL_SPELL, ArgumentType.OPTIONAL_REMAINING}, inGameOnly = true)
public static CommandResult onCast(CommandSource src, CommandContext context) {
	User user = Zephyr.getUserManager().getUser(((Player)src).getUniqueId());
	SpellManager manager = Zephyr.getSpellManager();
	if (context.getOne("spell").isPresent()) {
		Spell spell = manager.getSpell(context.<String>getOne("spell").get());
		Optional<String> options = context.<String>getOne("args");
		manager.cast(spell, new SpongeSpellContext(spell, user, options.isPresent() ? options.get().split(" ") : new String[0]));
		return CommandResult.success();
	} else {
		if (user.isCasting()) {
			user.setCasting(null, null);
		} else {
			user.sendMessage("Usage: /cast <spell> [args...]");
		}
		return CommandResult.success();
	}
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:19,代码来源:SpellCommand.java


示例9: getOwnerAs

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
/**
 * Get the region's owner.
 *
 * @param tClass get owner as who?
 * @return the owner.
 */
@Override
public < T > Optional< T > getOwnerAs( Class< T > tClass )
{
    if ( OglofusUtils.equalClass( tClass, Player.class ) )
    {
        return ( Optional< T > ) this.sponge.getServer().getPlayer( owner );
    } else
        if ( OglofusUtils.equalClass( tClass, User.class ) )
        {
            UserStorage storage;
            if ( ( storage = this.sponge.getGame().getServiceManager().provide( UserStorage.class ).orNull() ) !=
                    null )
            {
                return ( Optional< T > ) storage.get( owner ).orNull();
            }
        }
    return Optional.absent();
}
 
开发者ID:nikosgram13,项目名称:OglofusProtection,代码行数:25,代码来源:OglofusProtectionStaff.java


示例10: kick

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
/**
 * Kick a player to join at this area
 *
 * @param sender who want to kick the player
 * @param target the player
 * @return the response.
 */
@Override
public ActionResponse kick( Object sender, UUID target )
{
    if ( sender instanceof CommandSource )
    {
        if ( sender instanceof Player )
        {
            if ( hasOwnerAccess( ( ( Player ) sender ).getUniqueId() ) )
            {
                return this.kick( target );
            }
            return ActionResponse.Failure.setMessage( "access" );
        }
        if ( ( ( CommandSource ) sender ).hasPermission( "oglofus.protection.bypass.kick" ) )
        {
            return this.kick( target );
        }
        return ActionResponse.Failure.setMessage( "access" );
    }
    return ActionResponse.Failure.setMessage( "object" );
}
 
开发者ID:nikosgram13,项目名称:OglofusProtection,代码行数:29,代码来源:OglofusProtectionStaff.java


示例11: invite

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Override
public ActionResponse invite( Object sender, UUID target, ProtectionRegion region )
{
    if ( sender instanceof CommandSource )
    {
        if ( sender instanceof Player )
        {
            if ( region.getProtectionStaff().hasOwnerAccess( ( ( Player ) sender ).getUniqueId() ) )
            {
                //TODO: call the handler PlayerInviteHandler.
                return invite( target, region );
            }
            return ActionResponse.Failure.setMessage( "access" );
        }
        if ( ( ( CommandSource ) sender ).hasPermission( "oglofus.protection.bypass.invite" ) )
        {
            return invite( target, region );
        }
        return ActionResponse.Failure.setMessage( "access" );
    }
    return ActionResponse.Failure.setMessage( "object" );
}
 
开发者ID:nikosgram13,项目名称:OglofusProtection,代码行数:23,代码来源:OglofusInvitationManager.java


示例12: changeName

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
/**
 * Change the region's name.
 *
 * @param sender who want to change the name.
 * @param name   the new name.
 * @return the response.
 */
@Override
public ActionResponse changeName( Object sender, String name )
{
    if ( sender instanceof CommandSource )
    {
        if ( sender instanceof Player )
        {
            if ( getProtectionStaff().hasOwnerAccess( ( ( Player ) sender ).getUniqueId() ) )
            {
                return this.changeName( name );
            }
            return ActionResponse.Failure.setMessage( "access" );
        }
        if ( ( ( CommandSource ) sender ).hasPermission( "oglofus.protection.bypass" ) )
        {
            return this.changeName( name );
        }
        return ActionResponse.Failure.setMessage( "access" );
    }
    return ActionResponse.Failure.setMessage( "object" );
}
 
开发者ID:nikosgram13,项目名称:OglofusProtection,代码行数:29,代码来源:OglofusProtectionRegion.java


示例13: changeBlock

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void changeBlock(Boolean physics, BlockLoc block, BlockType type, byte data, Player player, ItemStack item)
{
  BlockBreakEvent breakEvent = new BlockBreakEvent(block, player);
  Bukkit.getPluginManager().callEvent(breakEvent);
  block.getWorld().playSound(block.getLocation(), SoundUtil.getSound(block.getType()), 0.2F, 1.0F);

  block.setTypeId(mat.getId(), physics.booleanValue());
  block.setData(data, physics.booleanValue());

  block.getWorld().playSound(block.getLocation(), SoundUtil.getSound(block.getType()), 1.0F, 1.0F);

  BlockPlaceEvent placeEvent = new BlockPlaceEvent(block, block.getState(), block, item, player, true);
  Bukkit.getPluginManager().callEvent(placeEvent);

  if (!physics.booleanValue())
  {
    updateBlockChange(block);
  }
}
 
开发者ID:Zingalicious,项目名称:ToolmanSponge,代码行数:21,代码来源:AbstractTool.java


示例14: placeBlock

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void placeBlock(Boolean physics, Block block, Material mat, byte data, Player player, ItemStack item)
{
  block.setTypeId(mat.getId(), physics.booleanValue());
  block.setData(data, physics.booleanValue());

  block.getWorld().playSound(block.getLocation(), SoundUtil.getSound(block.getType()), 1.0F, 1.0F);

  BlockPlaceEvent placeEvent = new BlockPlaceEvent(block, block.getState(), block, item, player, true);
  Bukkit.getPluginManager().callEvent(placeEvent);

  if (!physics.booleanValue())
  {
    updateBlockChange(block);
  }
}
 
开发者ID:Zingalicious,项目名称:ToolmanSponge,代码行数:17,代码来源:AbstractTool.java


示例15: onRangedUse

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
public void onRangedUse(Player player, ItemStack item, EntityInteractionType action)
{
	String displayName = MetadataUtil.getDisplayName(item.toContainer()).get();

	if (!PermissionsUtil.checkPermission(player, RANGED + displayName, false))
	{
		return;
	}
	for (Tool t : this.registeredTools)
	{
		if (!(t.getName().equals(displayName)))
		{
			continue;
		}
		t.onRangedUse(player, item, action);
	}
}
 
开发者ID:Zingalicious,项目名称:ToolmanSponge,代码行数:18,代码来源:ToolManager.java


示例16: onCloseUse

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
public boolean onCloseUse(BlockLoc clickedBlock, Direction direction, Player player, ItemStack item, EntityInteractionType action)
{
	String displayName = MetadataUtil.getDisplayName(item.toContainer()).get();

	if (!PermissionsUtil.checkPermission(player, RANGED + displayName, false))
	{
		return false;
    }
	for (Tool t : this.registeredTools)
	{
		if (!(t.getName().equals(displayName)))
		{
			continue;
		}
		t.onCloseUse(clickedBlock, direction, player, item, action);
		return true;
	}
	return false;
}
 
开发者ID:Zingalicious,项目名称:ToolmanSponge,代码行数:20,代码来源:ToolManager.java


示例17: getBlockFaceDirection

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
public Direction getBlockFaceDirection(BlockLoc block, Player player)
{
  Direction direction = null;

  ArrayList<BlockLoc> adjacentBlocks = new ArrayList<BlockLoc>();
  adjacentBlocks.add(block.getRelative(Direction.UP));
  adjacentBlocks.add(block.getRelative(Direction.DOWN));
  adjacentBlocks.add(block.getRelative(Direction.NORTH));
  adjacentBlocks.add(block.getRelative(Direction.SOUTH));
  adjacentBlocks.add(block.getRelative(Direction.EAST));
  adjacentBlocks.add(block.getRelative(Direction.WEST));

  for (BlockLoc b : adjacentBlocks)
  {
    if ((b == null) || (!(player.)
    {
      continue;
    }
    direction = block.;
    return blockFace;
  }

  return blockFace;
}
 
开发者ID:Zingalicious,项目名称:ToolmanSponge,代码行数:25,代码来源:BlockGetter.java


示例18: execute

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Override
public CommandResult execute(Optional<Claim> claimOptional, Tenant tenant, CommandContext args, Player player) throws CommandException {
    if (claimOptional.isPresent()){
        Claim claim = claimOptional.get();
        try {
            if (claim.getOwner().getId().equals(player.getUniqueId()) || player.hasPermission(Permissions.ADMINUNCLAIM))
            {
                plugin.getClaimManager().removeClaim(player.getLocation());
                plugin.getLanguageManager().sendMessage(player, Messages.LAND_UNCLAIMED, TextColors.GREEN);
            }
            else
                plugin.getLanguageManager().sendMessage(player, Messages.NO_ACCES_TO_UNCLAIM, TextColors.RED);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }else {
        plugin.getLanguageManager().sendMessage(player, Messages.NO_CLAIM_TO_UNCLAIM, TextColors.YELLOW);
    }
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:22,代码来源:UnclaimCommand.java


示例19: execute

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@Override
public CommandResult execute(Optional<Claim> claimOptional, Tenant tenant, CommandContext args, Player player) throws CommandException {
    if (claimOptional.isPresent()){
        Claim claim = claimOptional.get();
        languageManager.sendMessage(player, Messages.CLAIM_INFO, TextColors.AQUA,
                player.getWorld().getName(),
                String.valueOf(claim.getX()),
                String.valueOf(claim.getZ()),
                claim.getOwner().getName(),
                "",
                "");
    }else {
        languageManager.sendMessage(player, Messages.NO_CLAIM_FOUND, TextColors.YELLOW);
    }
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:17,代码来源:ClaimInfoCommand.java


示例20: onVehicleEnter

import org.spongepowered.api.entity.player.Player; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVehicleEnter(final VehicleEnterEvent event)
{
    if (event.getEntered() instanceof Player)
    {
        VehicleEnter action = this.newAction(VehicleEnter.class, event.getEntered().getWorld());
        if (action != null)
        {
            action.setVehicle(event.getVehicle());
            action.setLocation(event.getVehicle().getLocation());
            action.setPlayer((Player)event.getEntered());
            this.logAction(action);
        }
    }
    else
    {
        // TODO entity vehicle enter
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:20,代码来源:ListenerVehicle.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SymbolAxis类代码示例发布时间:2022-05-21
下一篇:
Java Completion类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap