Java Code Examples for org.bukkit.entity.Player#removeMetadata()
The following examples show how to use
org.bukkit.entity.Player#removeMetadata() .
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: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
private String addTeamJoinEntity(final Player player, String name) { for (Team t : game.getTeams()) { if (t.name.equals(name)) { if (player.hasMetadata(BEDWARS_TEAM_JOIN_METADATA)) { player.removeMetadata(BEDWARS_TEAM_JOIN_METADATA, Main.getInstance()); } player.setMetadata(BEDWARS_TEAM_JOIN_METADATA, new TeamJoinMetaDataValue(t)); new BukkitRunnable() { public void run() { if (!player.hasMetadata(BEDWARS_TEAM_JOIN_METADATA)) { return; } player.removeMetadata(BEDWARS_TEAM_JOIN_METADATA, Main.getInstance()); } }.runTaskLater(Main.getInstance(), 200L); return i18n("admin_command_click_right_on_entity_to_set_join").replace("%team%", t.name); } } return i18n("admin_command_team_is_not_exists"); }
Example 2
Source File: CommandDebug.java From TrMenu with MIT License | 6 votes |
@Override public void onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (player.hasMetadata("TrMenu-Debug")) { player.removeMetadata("TrMenu-Debug", TrMenu.getPlugin()); sender.sendMessage("§7Canceled..."); } else { player.setMetadata("TrMenu-Debug", new FixedMetadataValue(TrMenu.getPlugin(), "")); sender.sendMessage("§aEnabled..."); } return; } sender.sendMessage("§3--------------------------------------------------"); sender.sendMessage(""); sender.sendMessage("§2Total Menus: §6" + TrMenuAPI.getMenus().size()); sender.sendMessage("§2Cached Skulls: §6" + Skulls.getSkulls().size()); sender.sendMessage("§2Running Tasks: §6" + Bukkit.getScheduler().getActiveWorkers().stream().filter(t -> t.getOwner() == TrMenu.getPlugin()).count() + Bukkit.getScheduler().getPendingTasks().stream().filter(t -> t.getOwner() == TrMenu.getPlugin()).count()); sender.sendMessage("§2Metrics: §6" + MetricsHandler.getMetrics().isEnabled()); sender.sendMessage("§2TabooLib: §f" + Plugin.getVersion()); sender.sendMessage(""); sender.sendMessage("§2TrMenu Built-Time: §b" + YamlConfiguration.loadConfiguration(new InputStreamReader(Files.getResource(TrMenu.getPlugin(), "plugin.yml"))).getString("built-time", "Null")); sender.sendMessage(""); sender.sendMessage("§3--------------------------------------------------"); }
Example 3
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
private String addTeamJoinEntity(final Player player, String name) { for (Team t : game.getTeams()) { if (t.name.equals(name)) { if (player.hasMetadata(BEDWARS_TEAM_JOIN_METADATA)) { player.removeMetadata(BEDWARS_TEAM_JOIN_METADATA, Main.getInstance()); } player.setMetadata(BEDWARS_TEAM_JOIN_METADATA, new TeamJoinMetaDataValue(t)); new BukkitRunnable() { public void run() { if (!player.hasMetadata(BEDWARS_TEAM_JOIN_METADATA)) { return; } player.removeMetadata(BEDWARS_TEAM_JOIN_METADATA, Main.getInstance()); } }.runTaskLater(Main.getInstance(), 200L); return i18n("admin_command_click_right_on_entity_to_set_join").replace("%team%", t.name); } } return i18n("admin_command_team_is_not_exists"); }
Example 4
Source File: RecipeBuilder.java From ProRecipes with GNU General Public License v2.0 | 6 votes |
public void saveFurnace(ItemStack source, Player p){ p.removeMetadata("recipeBuilder", ProRecipes.getPlugin()); if(source.getType() != Material.AIR){ ItemStack ib = null; ib = storedItems.get(p.getName()).clone(); storedItems.remove(p.getName()); RecipeFurnace rec = new RecipeFurnace(ib, source); if(p.hasMetadata("recPermission")){ rec.setPermission(p.getMetadata("recPermission").get(0).asString()); p.removeMetadata("recPermission", ProRecipes.getPlugin()); } rec.register(); ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") , m.getMessage("Furnace_Saved", ChatColor.DARK_GREEN + "Your furnace recipe has been saved!")); ProRecipes.getPlugin().getRecipes().saveRecipes(false); }else{ ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") , m.getMessage("Recipe_Builder_Empty", ChatColor.DARK_RED + "You cannot save an empty recipe")); //return; } }
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: HolographicDisplaysInteraction.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public void onHologramTouch(final Player player, final Hologram holo) { if (!player.hasMetadata("bw-remove-holo") || (!player.isOp() && !player.hasPermission("bw.setup"))) { return; } player.removeMetadata("bw-remove-holo", BedwarsRel.getInstance()); BedwarsRel.getInstance().getServer().getScheduler() .runTask(BedwarsRel.getInstance(), new Runnable() { @Override public void run() { // remove all player holograms on this location for (Entry<Player, List<Hologram>> entry : HolographicDisplaysInteraction.this .getHolograms().entrySet()) { Iterator<Hologram> iterator = entry.getValue().iterator(); while (iterator.hasNext()) { Hologram hologram = iterator.next(); if (hologram.getX() == holo.getX() && hologram.getY() == holo.getY() && hologram.getZ() == holo.getZ()) { hologram.delete(); iterator.remove(); } } } Location holoLocation = HolographicDisplaysInteraction.this .getHologramLocationByLocation(holo.getLocation()); if (holoLocation != null) { HolographicDisplaysInteraction.this.hologramLocations.remove(holoLocation); HolographicDisplaysInteraction.this.updateHologramDatabase(); } player.sendMessage( ChatWriter.pluginMessage(ChatColor.GREEN + BedwarsRel._l("success.holoremoved"))); } }); }
Example 7
Source File: AssassinsBlade.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean effect(Event event, final Player player) { if(event instanceof PlayerInteractEvent) { if(!player.hasMetadata("ce.assassin")) if(player.isSneaking()) player.setMetadata("ce.assassin", new FixedMetadataValue(main, null)); player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, InvisibilityDuration, 0, true), true); player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "You hide in the shadows."); new BukkitRunnable() { @Override public void run() { if(player.hasMetadata("ce.assassin")) { player.removeMetadata("ce.assassin", main); player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "You are no longer hidden!"); } } }.runTaskLater(main, InvisibilityDuration); return true; } if(event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent e = ((EntityDamageByEntityEvent) event); if(e.getDamager() == player && player.hasMetadata("ce.assassin")) { e.setDamage(e.getDamage() * AmbushDmgMultiplier); player.removeMetadata("ce.assassin", main); player.removePotionEffect(PotionEffectType.INVISIBILITY); EffectManager.playSound(e.getEntity().getLocation(), "BLOCK_PISTON_EXTEND", 0.4f, 0.1f); player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, WeaknessLength, WeaknessLevel, false), true); player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "You are no longer hidden!"); } } return false; }
Example 8
Source File: StatsListener.java From ScoreboardStats with MIT License | 5 votes |
/** * Saves the stats to database if the player leaves * * @param quitEvent leave event * @see Database */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onQuit(PlayerQuitEvent quitEvent) { Player player = quitEvent.getPlayer(); database.getStats(player).ifPresent(database::saveAsync); //just remove our metadata to prevent memory leaks player.removeMetadata("player_stats", plugin); }
Example 9
Source File: PlayerListener.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerTeleportEvent(PlayerTeleportEvent event) { Player player = event.getPlayer(); player.removeMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, WorldGuardExtraFlagsPlugin.getPlugin()); }
Example 10
Source File: ItemBuilder.java From ProRecipes with GNU General Public License v2.0 | 5 votes |
public void closeItemBuilder(Player p){ p.removeMetadata("itemBuilder", ProRecipes.getPlugin()); close(p); if(p.hasMetadata("closed")){ p.removeMetadata("closed", ProRecipes.getPlugin()); } }
Example 11
Source File: ItemBuilder.java From ProRecipes with GNU General Public License v2.0 | 5 votes |
public void finish(Player p){ ItemStack i = p.getOpenInventory().getItem(0).clone(); if(!createdItems.contains(i)){ createdItems.add(i.clone()); } storedItems.remove(p.getName()); close(p); p.removeMetadata("closed", ProRecipes.getPlugin()); sendMessage(p, m.getMessage("Item_Builder_Title", ChatColor.GOLD + "Item Builder"), m.getMessage("Item_Builder_Done", ChatColor.DARK_GREEN + "Your item is in your inventory!")); p.getInventory().addItem(i); p.removeMetadata("itemBuilder", ProRecipes.getPlugin()); }
Example 12
Source File: ProRecipes.java From ProRecipes with GNU General Public License v2.0 | 5 votes |
public void removeMeta(Player p){ String[] s = {"recipeBuilder","recipeViewer","itemViewer","itemBuilder"}; for(String t : s){ if(p.hasMetadata(t)){ p.removeMetadata(t, this); } } }
Example 13
Source File: QuitEvent.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onQuit(PlayerQuitEvent event){ Player player = event.getPlayer(); if(player.hasMetadata(GlobalValues.STICK_MODE)){ player.removeMetadata(GlobalValues.STICK_MODE, sm); player.removeMetadata(GlobalValues.SELECTED_ENTITY, sm); player.removeMetadata(GlobalValues.WAITING_FOR_INPUT, sm); } }
Example 14
Source File: NMSUtilsHologramInteraction.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void handle(Player player, Hologram holo) { if (!player.hasMetadata("bw-remove-holo") || (!player.isOp() && !player.hasPermission(AdminCommand.ADMIN_PERMISSION))) { return; } player.removeMetadata("bw-remove-holo", Main.getInstance()); Main.getInstance().getServer().getScheduler().runTask(Main.getInstance(), () -> { // remove all player holograms on this location for (Entry<Player, List<Hologram>> entry : holograms.entrySet()) { Iterator<Hologram> iterator = entry.getValue().iterator(); while (iterator.hasNext()) { Hologram hologram = iterator.next(); if (hologram.getLocation().getX() == holo.getLocation().getX() && hologram.getLocation().getY() == holo.getLocation().getY() && hologram.getLocation().getZ() == holo.getLocation().getZ()) { hologram.destroy(); iterator.remove(); } } } Location holoLocation = getHologramLocationByLocation(holo.getLocation()); if (holoLocation != null) { hologramLocations.remove(holoLocation); updateHologramDatabase(); } player.sendMessage(i18n("holo_removed")); }); }
Example 15
Source File: SpleefPlayer.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
public void teleport(Location location) { validateOnline(); Player bukkitPlayer = getBukkitPlayer(); //Setting a metadata value to indicate that the next teleport is allowed bukkitPlayer.setMetadata(ALLOW_NEXT_TELEPORT_KEY, new FixedMetadataValue(heavySpleef.getPlugin(), true)); getBukkitPlayer().teleport(location); //Remove previously set metadata key bukkitPlayer.removeMetadata(ALLOW_NEXT_TELEPORT_KEY, heavySpleef.getPlugin()); }
Example 16
Source File: Blitz.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Player player = event.getEntity(); Optional<TeamModule> team = Teams.getTeamByPlayer(player); if (team.isPresent() && !team.get().isObserver()) { int oldMeta = this.getLives(player); player.removeMetadata("lives", Cardinal.getInstance()); player.setMetadata("lives", new LazyMetadataValue(Cardinal.getInstance(), LazyMetadataValue.CacheStrategy.NEVER_CACHE, new BlitzLives(oldMeta - 1))); if (this.getLives(player) == 0) { Teams.getTeamById("observers").get().add(player, true, false); player.removeMetadata("lives", Cardinal.getInstance()); } } }
Example 17
Source File: PatienceTester.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
public static void stopRunning(Player player, String key) { player.removeMetadata(key, uSkyBlock.getInstance()); }
Example 18
Source File: ConnectionListener.java From FastLogin with MIT License | 4 votes |
private void removeBlacklistStatus(Player player) { player.removeMetadata(plugin.getName(), plugin); }
Example 19
Source File: Powergloves.java From ce with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean effect(Event event, final Player player) { if(event instanceof PlayerInteractEntityEvent) { PlayerInteractEntityEvent e = (PlayerInteractEntityEvent) event; e.setCancelled(true); final Entity clicked = e.getRightClicked(); if(!player.hasMetadata("ce." + getOriginalName())) if(!clicked.getType().equals(EntityType.PAINTING) && !clicked.getType().equals(EntityType.ITEM_FRAME) && clicked.getPassenger() != player && player.getPassenger() == null) { player.setMetadata("ce." + getOriginalName(), new FixedMetadataValue(main, false)); player.setPassenger(clicked); player.getWorld().playEffect(player.getLocation(), Effect.ZOMBIE_CHEW_IRON_DOOR, 10); new BukkitRunnable() { @Override public void run() { player.getWorld().playEffect(player.getLocation(), Effect.CLICK2, 10); player.setMetadata("ce." + getOriginalName(), new FixedMetadataValue(main, true)); this.cancel(); } }.runTaskLater(main, ThrowDelayAfterGrab); new BukkitRunnable() { int GrabTime = MaxGrabtime; ItemStack current = player.getItemInHand(); @Override public void run() { if(current.equals(player.getItemInHand())) { current = player.getItemInHand(); if(GrabTime > 0) { if(!player.hasMetadata("ce." + getOriginalName())) { this.cancel(); } GrabTime--; } else if(GrabTime <= 0) { if(player.hasMetadata("ce." + getOriginalName())) { player.getWorld().playEffect(player.getLocation(), Effect.CLICK1, 10); player.removeMetadata("ce." + getOriginalName(), main); generateCooldown(player, getCooldown()); } clicked.leaveVehicle(); this.cancel(); } } else { player.removeMetadata("ce." + getOriginalName(), main); generateCooldown(player, getCooldown()); this.cancel(); } } }.runTaskTimer(main, 0l, 10l); } } else if(event instanceof PlayerInteractEvent) { if(player.hasMetadata("ce." + getOriginalName()) && player.getMetadata("ce." + getOriginalName()).get(0).asBoolean()) if(player.getPassenger() != null) { Entity passenger = player.getPassenger(); player.getPassenger().leaveVehicle(); passenger.setVelocity(player.getLocation().getDirection().multiply(ThrowSpeedMultiplier)); player.getWorld().playEffect(player.getLocation(), Effect.ZOMBIE_DESTROY_DOOR, 10); player.removeMetadata("ce." + getOriginalName(), main); return true; } } return false; }
Example 20
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)))); }