Java Code Examples for org.bukkit.entity.Player#getMetadata()
The following examples show how to use
org.bukkit.entity.Player#getMetadata() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Game.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
public void onPlayerTeleport(PlayerTeleportEvent event, SpleefPlayer player) { Player bukkitPlayer = player.getBukkitPlayer(); if (bukkitPlayer.hasMetadata(SpleefPlayer.ALLOW_NEXT_TELEPORT_KEY)) { List<MetadataValue> values = bukkitPlayer.getMetadata(SpleefPlayer.ALLOW_NEXT_TELEPORT_KEY); for (MetadataValue value : values) { if (value.getOwningPlugin() != heavySpleef.getPlugin()) { continue; } if (value.asBoolean()) { return; } } } event.setCancelled(true); }
Example 2
Source File: BukkitPartyPlayerImpl.java From Parties with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean isVanished() { Player player = Bukkit.getPlayer(this.getPlayerUUID()); if (player != null) { for (MetadataValue meta : player.getMetadata("vanished")) { if (meta.asBoolean()) return true; } } return false; }
Example 3
Source File: MapBuilder.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority=EventPriority.HIGH) public void nexusHelperCheck(PlayerInteractEvent event) { if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { final Player player = event.getPlayer(); TeamBlock t = null; if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Red.getName())) t = TeamBlock.Red; else if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Blue.getName())) t = TeamBlock.Blue; else if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Green.getName())) t = TeamBlock.Green; else if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Yellow.getName())) t = TeamBlock.Yellow; if(t != null) { //They made a click with a team block event.setCancelled(true); List<MetadataValue> vals = player.getMetadata("TeamHandler"); if(vals != null && vals.size() == 1) { Object obj = vals.get(0).value(); if(obj != null && obj instanceof TeamBlockHandler) { ((TeamBlockHandler)obj).onBlockClick(player, t.Team, event.getAction(), event.getClickedBlock(),event.getBlockFace()); } } } } }
Example 4
Source File: HookBukkitVanish.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public static boolean isVanished(Player player) { if(player == null) return false; List<MetadataValue> metaList = player.getMetadata("vanished"); for(MetadataValue meta : metaList) { boolean value = meta.asBoolean(); if(value) return true; } return false; }
Example 5
Source File: DeathStandsModule.java From UHC with MIT License | 5 votes |
protected EnumMap<EquipmentSlot, ItemStack> getSavedSlots(Player player) { for (final MetadataValue value : player.getMetadata(StandItemsMetadata.KEY)) { if (!(value instanceof StandItemsMetadata)) continue; // remove the metadata player.removeMetadata(StandItemsMetadata.KEY, value.getOwningPlugin()); // return the map return ((StandItemsMetadata) value).value(); } return Maps.newEnumMap(EquipmentSlot.class); }
Example 6
Source File: PatienceTester.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static boolean isRunning(Player player, String key) { if (player.hasMetadata(key)) { List<MetadataValue> metadata = player.getMetadata(key); MetadataValue metadataValue = metadata.size() > 0 ? metadata.get(0) : null; if (metadataValue == null || metadataValue.asLong() < System.currentTimeMillis()) { player.removeMetadata(key, uSkyBlock.getInstance()); return false; } player.sendMessage(getMessage()); return true; } return false; }
Example 7
Source File: Database.java From ScoreboardStats with MIT License | 5 votes |
public Optional<PlayerStats> getStats(Player request) { if (request != null) { for (MetadataValue metadata : request.getMetadata(METAKEY)) { if (metadata.value() instanceof PlayerStats) { return Optional.of((PlayerStats) metadata.value()); } } } return Optional.empty(); }
Example 8
Source File: Checker.java From Harbor with MIT License | 4 votes |
public static boolean isVanished(final Player player) { for (MetadataValue meta : player.getMetadata("vanished")) if (meta.asBoolean()) return true; return false; }
Example 9
Source File: AntiVPN.java From AntiVPN with MIT License | 4 votes |
private boolean isVanished(Player player) { for (MetadataValue meta : player.getMetadata("vanished")) { if (meta.asBoolean()) return true; } return false; }
Example 10
Source File: PlayerStatesImpl.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
private boolean get(Player player, String key, boolean fallback) { final MetadataValue value = player.getMetadata(key, plugin); return value != null ? value.asBoolean() : fallback; }
Example 11
Source File: AreaCommand.java From AnnihilationPro with MIT License | 4 votes |
@Override public boolean onCommand(CommandSender sender, Command cmd, String label ,String[] args) { if(sender instanceof Player) { final Player player = (Player)sender; if(player.hasPermission("A.Area")) { if(args.length > 0) { if(args[0].equalsIgnoreCase("create") && args.length > 1) { List<MetadataValue> corner1 = player.getMetadata("A.Loc1"); List<MetadataValue> corner2 = player.getMetadata("A.Loc2"); if(corner1 != null && corner2 != null && corner1.size() == 1 && corner2.size() == 1) { Loc one = (Loc)corner1.get(0).value(); Loc two = (Loc)corner2.get(0).value(); if(one != null && two != null) { player.removeMetadata("A.Loc1", AnnihilationMain.getInstance()); player.removeMetadata("A.Loc2", AnnihilationMain.getInstance()); Areas areas = null; if(one.getWorld().equals(two.getWorld())) { if(Game.LobbyMap != null && Game.LobbyMap.getWorldName().equalsIgnoreCase(one.getWorld())) areas = Game.LobbyMap.getAreas(); else if(Game.getGameMap() != null && Game.getGameMap().getWorldName().equalsIgnoreCase(one.getWorld())) areas = Game.getGameMap().getAreas(); } if(areas != null) { Area a = new Area(one, two, args[1]); boolean allowPVP = true; boolean allowDamage = true; boolean allowHuger = true; if(args.length > 2) { if(args[2].equalsIgnoreCase("allow")) allowPVP = true; else if(args[2].equalsIgnoreCase("disallow")) allowPVP = false; if(args.length > 3) { if(args[3].equalsIgnoreCase("allow")) allowDamage = true; else if(args[3].equalsIgnoreCase("disallow")) allowDamage = false; if(args.length > 4) { if(args[4].equalsIgnoreCase("allow")) allowHuger = true; else if(args[4].equalsIgnoreCase("disallow")) allowHuger = false; } } } a.setAllowPVP(allowPVP); a.setAllowDamage(allowDamage); a.setAllowHunger(allowHuger); areas.addArea(a); sender.sendMessage(ChatColor.LIGHT_PURPLE+"Area "+ChatColor.GOLD+a.getName()+ChatColor.LIGHT_PURPLE+" added"); sender.sendMessage("Values: PVP = "+allowPVP+", Damage = "+allowDamage+", Hunger = "+allowHuger); } else sender.sendMessage(ChatColor.RED+"The worlds of the corners either don't match each other, dont match the loaded game world, or dont match the lobby world."); } else sender.sendMessage(ChatColor.RED+"You must have 2 corners set to create an area."); } else sender.sendMessage(ChatColor.RED+"You must have 2 corners set to create an area."); } else if(args[0].equalsIgnoreCase("delete") && args.length > 1) { handleDelete(player,args[1]); } else sender.sendMessage(ChatColor.LIGHT_PURPLE+"/Area "+ChatColor.GOLD+"[create,delete] [name] [allow-PvP?]"); } else sender.sendMessage(ChatColor.LIGHT_PURPLE+"/Area "+ChatColor.GOLD+"[create,delete] [name] [allow-PvP?]"); } else sender.sendMessage(ChatColor.RED+"You do not have permission to use this command."); } else sender.sendMessage("You must be a player to select areas."); return true; }
Example 12
Source File: EntityListener.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGH) public void onInteractEntity(PlayerInteractAtEntityEvent event) { if (event.getRightClicked() == null) { return; } Entity entity = event.getRightClicked(); Player player = event.getPlayer(); if (!player.hasMetadata("bw-addteamjoin")) { if (!(entity instanceof LivingEntity)) { return; } LivingEntity livEntity = (LivingEntity) entity; Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() != GameState.WAITING) { return; } Team team = game.getTeam(ChatColor.stripColor(livEntity.getCustomName())); if (team == null) { return; } game.playerJoinTeam(player, team); event.setCancelled(true); return; } List<MetadataValue> values = player.getMetadata("bw-addteamjoin"); if (values == null || values.size() == 0) { return; } event.setCancelled(true); TeamJoinMetaDataValue value = (TeamJoinMetaDataValue) values.get(0); if (!((boolean) value.value())) { return; } if (!(entity instanceof LivingEntity)) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(player, "errors.entitynotcompatible"))); return; } LivingEntity living = (LivingEntity) entity; living.setRemoveWhenFarAway(false); living.setCanPickupItems(false); living.setCustomName(value.getTeam().getChatColor() + value.getTeam().getDisplayName()); living.setCustomNameVisible( BedwarsRel.getInstance().getBooleanConfig("jointeam-entity.show-name", true)); if (living.getType().equals(EntityType.valueOf("ARMOR_STAND"))) { Utils.equipArmorStand(living, value.getTeam()); } player.removeMetadata("bw-addteamjoin", BedwarsRel.getInstance()); player.sendMessage(ChatWriter .pluginMessage( ChatColor.GREEN + BedwarsRel._l(player, "success.teamjoinadded", ImmutableMap.of("team", value.getTeam().getChatColor() + value.getTeam().getDisplayName() + ChatColor.GREEN)))); }