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


Java Player.getUniqueId方法代码示例

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


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

示例1: setVale

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setVale(Player player, int amount) throws SQLException {
    UUID uuid = player.getUniqueId();
    PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("UPDATE vale_eco SET amount = "+amount+" WHERE uuid = '"+uuid.toString()+"'");
    stmt.executeUpdate();

    ItemStack item = new ItemStack(Material.EMERALD, 1);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(ChatColor.GREEN.toString() + getVale(player) + (getVale(player)==1?" Vale":" Vales"));
    meta.addEnchant(Enchantment.LUCK, 1, true);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    item.setItemMeta(meta);
    if(plugin.getConfig().getString("valeitemininv").equals("true")){
        player.getInventory().setItem(8, item);
    }

}
 
开发者ID:Warvale,项目名称:NetworkCore,代码行数:17,代码来源:ValeUtil.java

示例2: changePlayerName

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Changes the name displayed above the player's head. Please note that these names
 * must follow the regular rules of minecraft names (ie maximum 16 characters)
 *
 * @param player  the player
 * @param newName the new name of the player
 */
public void changePlayerName(Player player, String newName) {
    Validate.isTrue(enabled, "NameTagChanger is disabled");
    Validate.notNull(player, "player cannot be null");
    Validate.notNull(newName, "newName cannot be null");
    Validate.isTrue(!newName.equals(player.getName()), "The new name cannot be the same of the player's! If you intended to reset the player's name, use resetPlayerName()!");
    Validate.isTrue(newName.length() <= 16, "newName cannot be longer than 16 characters!");
    GameProfileWrapper profile = new GameProfileWrapper(player.getUniqueId(), newName);
    if (gameProfiles.containsKey(player.getUniqueId())) {
        profile.getProperties().putAll(gameProfiles.get(player.getUniqueId()).getProperties());
    } else {
        // If the player doesn't already have a skin specified, make sure to carry over their default one.
        profile.getProperties().putAll(packetHandler.getDefaultPlayerProfile(player).getProperties());
    }
    gameProfiles.put(player.getUniqueId(), profile);
    updatePlayer(player, player.getName());
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:24,代码来源:NameTagChanger.java

示例3: onClick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e){
    Player p = (Player) e.getWhoClicked();
    WCUser user = new WCUser(p.getUniqueId());
    Inventory inv = e.getClickedInventory();
    ItemStack i = e.getCurrentItem();

    switch (ChatColor.stripColor(inv.getName())){
        case "Servidores":
            switch (e.getSlot()){
                case 21:
                    user.sendToServer("survival");
                    break;

                default:
                    break;
            }
            break;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:21,代码来源:InventoryEvent.java

示例4: getPlayerData

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * ��ȡPlayerData
 * @param rs ����·��
 * @param p Player����
 * @return PlayerData����
 */
public static PlayerData getPlayerData(Player p){
	File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
	PlayerData pd;
	if(!data.exists()){
		try {data.createNewFile();} catch (IOException e) {}
		pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(), 
											rs.getThirstMax(), 0, 37,0, rs.getPhysical_strength());
		return pd;
	}
	YamlConfiguration dataC=YamlConfiguration.loadConfiguration(data);
	HashMap<String,Object[]> sickKind=new HashMap<String,Object[]>();
	for(String temp:dataC.getStringList("rSickKind")){
		List<String> l=dataC.getStringList("sickKind."+temp);
		sickKind.put(temp,new Object[]{l.get(0),l.get(1),l.get(2),l.get(3)} );
	}
	pd=new PlayerData( p.getUniqueId(),dataC.getString("world"), dataC.getDouble("sleep"),
			dataC.getDouble("thirst"), dataC.getDouble("temperature"), dataC.getDouble("weight"), 
			dataC.getDouble("physical_strength"),dataC.getBoolean("sick"), 
			dataC.getBoolean("isSleep"),Byte.parseByte(dataC.getString("light")),sickKind);
	return pd;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:28,代码来源:Utils.java

示例5: onArcherJumpClick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onArcherJumpClick(PlayerInteractEvent event)
{
    Action action = event.getAction();
    if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
            (event.hasItem()) && (event.getItem().getType() == Material.FEATHER))
    {
        if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
            return;
        }
        Player player = event.getPlayer();
        UUID uuid = player.getUniqueId();
        long timestamp = this.archerJumpCooldowns.get(uuid);
        long millis = System.currentTimeMillis();
        long remaining = timestamp == this.archerJumpCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
        if (remaining > 0L)
        {
            player.sendMessage(ChatColor.RED + "Cannot use Jump Boost for another " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
        }
        else
        {
            ItemStack stack = player.getItemInHand();
            if (stack.getAmount() == 1) {
                player.setItemInHand(new ItemStack(Material.AIR, 1));
            } else {
                stack.setAmount(stack.getAmount() - 1);
            }
            player.sendMessage(ChatColor.GREEN + "Jump Boost 4 activated for 7 seconds.");

            this.plugin.getEffectRestorer().setRestoreEffect(player, ARCHER_JUMP_EFFECT);
            this.archerJumpCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + ARCHER_JUMP_COOLDOWN_DELAY);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:ArcherClass.java

示例6: Team

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * A team with a leader.
 *
 * @param leader The leader of the team
 */
public Team(Player leader) {
  checkToModify();
  this.leader = leader.getUniqueId();
  join(leader);

  //TODO: Implement colored prefixes
  this.prefix = ChatColor.WHITE.toString();

  OpenUHC.getCurrentGame().getTeams().add(this);
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:16,代码来源:Team.java

示例7: getValue

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public String getValue(Player player, String key) {
    UUID playersUUID = player.getUniqueId();
    if (isAvailable(playersUUID)) {
        if (storage.containsKey(playersUUID) && storage.get(playersUUID).containsKey(key)) {
            return storage.get(playersUUID).get(key);
        }
    }
    return null;
}
 
开发者ID:srbinas,项目名称:bankomat,代码行数:10,代码来源:ChatInputAdvisor.java

示例8: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "Only players can leave faction.");
        return true;
    }

    Player player = (Player) sender;
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);

    if (playerFaction == null) {
        sender.sendMessage(ChatColor.RED + "You are not in a faction.");
        return true;
    }

    UUID uuid = player.getUniqueId();
    if (playerFaction.getMember(uuid).getRole() == Role.LEADER) {
        sender.sendMessage(ChatColor.RED + "You cannot leave factions as a leader. Either use " + ChatColor.GOLD + '/' + label + " disband" + ChatColor.RED + " or " + ChatColor.GOLD + '/' + label
                + " leader" + ChatColor.RED + '.');

        return true;
    }

    if (playerFaction.removeMember(player, player, player.getUniqueId(), false, false)) {
        sender.sendMessage(ChatColor.YELLOW + "Successfully left the faction.");
        playerFaction.broadcast(Relation.ENEMY.toChatColour() + sender.getName() + ChatColor.YELLOW + " has left the faction.");
    }

    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:31,代码来源:FactionLeaveArgument.java

示例9: onPlayerTeleport

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    Player player = event.getPlayer();
    UUID uuid = player.getUniqueId();
    if (getRemaining(uuid) > 0L)
    {
        Location from = (Location)this.startedLocations.get(uuid);
        checkMovement(player, from, event.getTo());
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:StuckTimer.java

示例10: LoggerEntityHuman

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private LoggerEntityHuman(Player player, WorldServer world) {
    super(MinecraftServer.getServer(), world, new GameProfile(player.getUniqueId(), player.getName()), new PlayerInteractManager((World)world));
    Location location = player.getLocation();
    double x = location.getX();
    double y = location.getY();
    double z = location.getZ();
    float yaw = location.getYaw();
    float pitch = location.getPitch();
    new FakePlayerConnection(this);
    this.playerConnection.a(x, y, z, yaw, pitch);
    EntityPlayer originPlayer = ((CraftPlayer)player).getHandle();
    this.lastDamager = originPlayer.lastDamager;
    this.invulnerableTicks = originPlayer.invulnerableTicks;
    this.combatTracker = originPlayer.combatTracker;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:16,代码来源:LoggerEntityHuman.java

示例11: GamePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public GamePlayer(Player player)
{
    this.uuid = player.getUniqueId();

    this.coins = 0;
    this.spectator = false;

    this.startTime = -1;
    this.playedTime = 0;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:11,代码来源:GamePlayer.java

示例12: Economy

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public Economy(Player p){
    this(new TWDPlayer(p.getUniqueId()));
}
 
开发者ID:cadox8,项目名称:WC,代码行数:4,代码来源:Economy.java

示例13: tick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void tick(EventTimer eventTimer, EventFaction eventFaction) {
    ConquestFaction conquestFaction = (ConquestFaction) eventFaction;
    List<CaptureZone> captureZones = conquestFaction.getCaptureZones();
    for (CaptureZone captureZone : captureZones) {
        captureZone.updateScoreboardRemaining();
        Player cappingPlayer = captureZone.getCappingPlayer();
        if (cappingPlayer == null) continue;

        // The capture zone has been controlled.
        long remainingMillis = captureZone.getRemainingCaptureMillis();
        if (remainingMillis <= 0L) {
            UUID uuid = cappingPlayer.getUniqueId();

            PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(uuid);
            if (playerFaction != null) {
                int newPoints = addPoints(playerFaction, 1);
                if (newPoints < SettingsYML.CONQUEST_REQUIRED_WIN_POINTS) {
                    // Reset back to the default for this tracker.
                    captureZone.setRemainingCaptureMillis(captureZone.getDefaultCaptureMillis());
                    Bukkit.broadcastMessage(ChatColor.YELLOW + "[" + eventFaction.getName() + "] " +
                            ChatColor.RED + ChatColor.BOLD + playerFaction.getName() +
                            ChatColor.GOLD + " gained " + 1 + " point for capturing " + captureZone.getDisplayName() + ChatColor.GOLD + ". " +
                            ChatColor.AQUA + '(' + newPoints + '/' + SettingsYML.CONQUEST_REQUIRED_WIN_POINTS + ')');
                } else {
                    // Clear all the points for the next Conquest event.
                    synchronized (factionPointsMap) {
                        factionPointsMap.clear();
                    }

                    plugin.getTimerManager().getEventTimer().handleWinner(cappingPlayer);
                    return;
                }
            }
            return;
        }

        int remainingSeconds = (int) Math.round((double) remainingMillis / 1000L);
        if (remainingSeconds % 5 == 0) {
            cappingPlayer.sendMessage(ChatColor.YELLOW + "[" + eventFaction.getName() + "] " + ChatColor.GOLD +
                    "Attempting to control " + ChatColor.YELLOW + captureZone.getDisplayName() + ChatColor.GOLD + ". " +
                    ChatColor.YELLOW + '(' + remainingSeconds + "s)");
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:46,代码来源:ConquestTracker.java

示例14: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "Only players can set faction captains.");
        return true;
    }

    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    Player player = (Player) sender;
    UUID uuid = player.getUniqueId();

    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(uuid);

    if (playerFaction == null) {
        sender.sendMessage(ChatColor.RED + "You are not in a faction.");
        return true;
    }

    if (playerFaction.getMember(uuid).getRole() != Role.LEADER) {
        sender.sendMessage(ChatColor.RED + "You must be a faction leader to assign members as a captain.");
        return true;
    }

    FactionMember targetMember = playerFaction.getMember(args[1]);

    if (targetMember == null) {
        sender.sendMessage(ChatColor.RED + "That player is not in your faction.");
        return true;
    }

    if (targetMember.getRole() != Role.MEMBER) {
        sender.sendMessage(ChatColor.RED + "You can only assign captains to members, " + targetMember.getName() + " is a " + targetMember.getRole().getName() + '.');
        return true;
    }

    Role role = Role.CAPTAIN;
    targetMember.setRole(role);

    playerFaction.broadcast(Relation.MEMBER.toChatColour() + role.getAstrix() + targetMember.getName() + ChatColor.YELLOW + " has been assigned as a faction captain.");
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:46,代码来源:FactionPromoteArgument.java

示例15: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
        return true;
    }

    if (args.length < 3) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    Player player = (Player) sender;
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);

    if (playerFaction == null) {
        sender.sendMessage(ChatColor.RED + "You are not in a faction.");
        return true;
    }

    UUID uuid = player.getUniqueId();

    if (playerFaction.getMember(uuid).getRole() == Role.MEMBER) {
        sender.sendMessage(ChatColor.RED + "You must be a faction officer to create subclaims.");
        return true;
    }

    if (args[2].length() < SettingsYML.SUBCLAIM_NAME_CHARACTERS_MIN) {
        sender.sendMessage(ChatColor.RED + "Subclaim names must have at least " + SettingsYML.SUBCLAIM_NAME_CHARACTERS_MIN + " characters.");
        return true;
    }

    if (args[2].length() > SettingsYML.SUBCLAIM_NAME_CHARACTERS_MAX) {
        sender.sendMessage(ChatColor.RED + "Subclaim names cannot be longer than " + SettingsYML.SUBCLAIM_NAME_CHARACTERS_MAX + " characters.");
        return true;
    }

    if (!JavaUtils.isAlphanumeric(args[2])) {
        sender.sendMessage(ChatColor.RED + "Subclaim names may only be alphanumeric.");
        return true;
    }

    for (Claim claim : playerFaction.getClaims()) {
        if (claim.getSubclaim(args[2]) != null) {
            sender.sendMessage(ChatColor.RED + "Your faction already has a subclaim named " + args[2] + '.');
            return true;
        }
    }

    Map<UUID, ClaimSelection> selectionMap = plugin.getClaimHandler().claimSelectionMap;
    ClaimSelection claimSelection = selectionMap.get(uuid);

    if (claimSelection == null || !claimSelection.hasBothPositionsSet()) {
        sender.sendMessage(ChatColor.RED + "You have not set both positions of this subclaim.");
        return true;
    }

    Subclaim subclaim = new Subclaim(playerFaction, claimSelection.getPos1(), claimSelection.getPos2());
    subclaim.setY1(ClaimHandler.MIN_CLAIM_HEIGHT);
    subclaim.setY2(ClaimHandler.MAX_CLAIM_HEIGHT);
    subclaim.setName(args[2]);
    if (plugin.getClaimHandler().tryCreatingSubclaim(player, subclaim)) {
        plugin.getVisualiseHandler().clearVisualBlock(player, subclaim.getMinimumPoint());
        plugin.getVisualiseHandler().clearVisualBlock(player, subclaim.getMaximumPoint());
        selectionMap.remove(uuid);
    }

    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:70,代码来源:FactionSubclaimCreateArgument.java


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