Java Code Examples for org.bukkit.metadata.FixedMetadataValue

The following examples show how to use org.bukkit.metadata.FixedMetadataValue. These examples are extracted from open source projects. 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 Project: TrMenu   Source File: CommandDebug.java    License: MIT License 6 votes vote down vote up
@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 2
@EventHandler
public void onDamageReceived(EntityDamageEvent event) {
    if(event.getEntity() instanceof LivingEntity){
        if(StackTools.hasValidStackData(event.getEntity())){
            LivingEntity entity = (LivingEntity) event.getEntity();
            if(sm.getCustomConfig().getBoolean("kill-step-damage.enabled")){
                double healthAfter = entity.getHealth() - event.getFinalDamage();
                if(healthAfter <= 0){
                    entity.setMetadata(GlobalValues.LEFTOVER_DAMAGE, new FixedMetadataValue(sm, Math.abs(healthAfter)));
                }
            }

            if(!sm.getCustomConfig().getStringList("multiply-damage-received.cause-blacklist")
                    .contains(event.getCause().toString())) {
                if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK){
                    return;
                }
                int stackSize = StackTools.getSize(entity);
                double extraDamage = event.getDamage() + ((event.getDamage() * (stackSize - 1) * 0.25));
                event.setDamage(extraDamage);
            }
        }
    }
}
 
Example 3
@EventHandler
public void onStickInteract(PlayerInteractEntityEvent event){
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    if(!(entity instanceof Mob)){
        return;
    }
    if(event.getHand() != EquipmentSlot.HAND) {
        return;
    }
    if (sm.getStickTools().isStackingStick(player.getInventory().getItemInMainHand())) {
        if (player.isSneaking()) {
            sm.getStickTools().toggleMode(player);
        } else {
            if(!(StackTools.hasValidMetadata(player, GlobalValues.STICK_MODE))){
                player.setMetadata(GlobalValues.STICK_MODE, new FixedMetadataValue(sm, 1));
            }
            sm.getStickTools().performAction(player, entity);
        }
    }
}
 
Example 4
Source Project: VoxelGamesLibv2   Source File: SignPlaceholders.java    License: MIT License 6 votes vote down vote up
@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()));
        }
    }
}
 
Example 5
Source Project: VoxelGamesLibv2   Source File: SkullPlaceHolders.java    License: MIT License 6 votes vote down vote up
@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 Skull) {
            Skull skull = (Skull) event.getClickedBlock().getState();
            if (skull.hasMetadata("UpdateCooldown")) {
                long cooldown = skull.getMetadata("UpdateCooldown").get(0).asLong();
                if (cooldown > System.currentTimeMillis() - 1 * 1000) {
                    return;
                }
            }
            skull.update();
            skull.setMetadata("UpdateCooldown", new FixedMetadataValue(voxelGamesLib, System.currentTimeMillis()));
        }
    }
}
 
Example 6
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void openRecipeBuilder(final Player p, final String type){
	ItemBuilder.close(p);
	ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") , m.getMessage("Recipe_Builder_Insert", ChatColor.DARK_GREEN + "Insert the desired result"));
	
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){

		@Override
		public void run() {
			p.setMetadata("recipeBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "itemRequest" + type));
			p.openWorkbench(null, true);
			//Inventory i = RPGRecipes.getPlugin().getServer().createInventory(p, InventoryType.WORKBENCH, "ItemBuilder");
			//p.openInventory(i);
		}
		
	}, ProRecipes.getPlugin().wait);
	
}
 
Example 7
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void openShapeless(final Player p) {
	final ItemStack i = p.getOpenInventory().getItem(0).clone();
	ItemBuilder.close(p);
	p.setMetadata("closed", new FixedMetadataValue(ProRecipes.getPlugin(), ""));
	ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") ,  m.getMessage("Recipe_Builder_Add", ChatColor.DARK_GREEN + "Add your ingredients! Close to save recipe."));
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){
		
		@Override
		public void run() {
			p.setMetadata("recipeBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "craftRecipeShapeless"));
			p.openWorkbench(null, true);
			//p.removeMetadata("closed", RPGRecipes.getPlugin());
			p.getOpenInventory().setItem(0, i);
			//Inventory i = RPGRecipes.getPlugin().getServer().createInventory(p, InventoryType.WORKBENCH, "ItemBuilder");
			//p.openInventory(i);
		}
		
	}, ProRecipes.getPlugin().wait);
	
}
 
Example 8
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void openShaped(final Player p) {
	final ItemStack i = p.getOpenInventory().getItem(0).clone();
	
	ItemBuilder.close(p);
	p.setMetadata("closed", new FixedMetadataValue(ProRecipes.getPlugin(), ""));
	ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") ,  m.getMessage("Recipe_Builder_Add", ChatColor.DARK_GREEN + "Add your ingredients! Close to save recipe."));
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){

		@Override
		public void run() {
			p.setMetadata("recipeBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "craftRecipeShaped"));
			p.openWorkbench(null, true);
			//p.removeMetadata("closed", RPGRecipes.getPlugin());
			p.getOpenInventory().setItem(0, i);
			//Inventory i = RPGRecipes.getPlugin().getServer().createInventory(p, InventoryType.WORKBENCH, "ItemBuilder");
			//p.openInventory(i);
		}
		
	}, ProRecipes.getPlugin().wait);
	
}
 
Example 9
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void openFurnace(final Player p) {
	
	final ItemStack i = p.getOpenInventory().getItem(0).clone();
	
	ItemBuilder.close(p);
	p.setMetadata("closed", new FixedMetadataValue(ProRecipes.getPlugin(), ""));
	ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") ,  m.getMessage("Recipe_Builder_Furnace", ChatColor.DARK_GREEN + "Add your source! Close to save recipe."));
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){

		@Override
		public void run() {
			p.setMetadata("recipeBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "craftRecipeFurnace"));
			p.openWorkbench(null, true);
			p.getOpenInventory().setItem(0, i);
		}
		
	}, ProRecipes.getPlugin().wait);
}
 
Example 10
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void openMutliCraft(final Player p){
	
	ItemBuilder.close(p);
	p.setMetadata("closed", new FixedMetadataValue(ProRecipes.getPlugin(), ""));
	ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder")  + ": " + m.getMessage("Recipe_Builder_MultiCraft_Title", "Multi-Craft"),  
			m.getMessage("Recipe_Builder_MultiCraft_Add", ChatColor.DARK_GREEN + "Add ingredients on left, results on right"));
	
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){

		@Override
		public void run() {
			p.setMetadata("recipeBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "craftRecipeChest"));
			p.openInventory(ProRecipes.getPlugin().getRecipes().createMultiTable(p, 0));
			
		}
		
	}, ProRecipes.getPlugin().wait);
}
 
Example 11
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
@EventHandler
public void onTalk(AsyncPlayerChatEvent event){
	if(event.getPlayer().hasMetadata("recipeBuilder")){
		String step = event.getPlayer().getMetadata("recipeBuilder").get(0).asString();
		if(step.equalsIgnoreCase("choosePermission")){
			if(event.getMessage().equalsIgnoreCase("no")){
				event.setCancelled(true);
				openChoice(event.getPlayer());
				return;
			}
			event.getPlayer().setMetadata("recPermission", new FixedMetadataValue(ProRecipes.getPlugin(), ChatColor.stripColor(event.getMessage())));
			event.setCancelled(true);
			openChoice(event.getPlayer());
		}
	}
}
 
Example 12
Source Project: ProRecipes   Source File: ItemBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void openItemBuilder(final Player p){
	sendMessage(p,  m.getMessage("Item_Builder_Title", ChatColor.GOLD + "Item Builder"),  m.getMessage("Item_Builder_Insert", ChatColor.DARK_GREEN + "Insert a desired itemstack to modify."));
	
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){

		@Override
		public void run() {
			p.closeInventory();
			p.setMetadata("itemBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "itemRequest"));
			p.openWorkbench(null, true);
			//Inventory i = RPGRecipes.getPlugin().getServer().createInventory(p, InventoryType.WORKBENCH, "ItemBuilder");
			//p.openInventory(i);
		}
		
	}, ProRecipes.getPlugin().wait);
	
}
 
Example 13
Source Project: MapManager   Source File: DefaultMapWrapper.java    License: MIT License 6 votes vote down vote up
@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(MAP_MATERIAL, 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);
}
 
Example 14
Source Project: uSkyBlock   Source File: SpawnEvents.java    License: GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event == null || !plugin.getWorldManager().isSkyAssociatedWorld(event.getLocation().getWorld())) {
        return; // Bail out, we don't care
    }
    if (!event.isCancelled() && ADMIN_INITIATED.contains(event.getSpawnReason())) {
        return; // Allow it, the above method would have blocked it if it should be blocked.
    }
    checkLimits(event, event.getEntity().getType(), event.getLocation());
    if (event.getEntity() instanceof WaterMob) {
        Location loc = event.getLocation();
        if (isDeepOceanBiome(loc) && isPrismarineRoof(loc)) {
            loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN);
            event.setCancelled(true);
        }
    }
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BUILD_WITHER && event.getEntity() instanceof Wither) {
        IslandInfo islandInfo = plugin.getIslandInfo(event.getLocation());
        if (islandInfo != null && islandInfo.getLeader() != null) {
            event.getEntity().setCustomName(I18nUtil.tr("{0}''s Wither", islandInfo.getLeader()));
            event.getEntity().setMetadata("fromIsland", new FixedMetadataValue(plugin, islandInfo.getName()));
        }
    }
}
 
Example 15
Source Project: CardinalPGM   Source File: PrivateMessageCommands.java    License: MIT License 6 votes vote down vote up
@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(ChatConstant.ERROR_PLAYER_COMMAND.getMessage(ChatUtil.getLocale(sender)));
    }
    Player player = (Player) sender;
    if (!player.hasMetadata("reply")) {
        throw new CommandException(ChatConstant.ERROR_NO_MESSAGES.getMessage(ChatUtil.getLocale(sender)));
    }
    Player target = (Player) player.getMetadata("reply").get(0).value();
    if (target == null) {
        throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_FOUND.getMessage(ChatUtil.getLocale(sender)));
    }
    if (Settings.getSettingByName("PrivateMessages") == null || Settings.getSettingByName("PrivateMessages").getValueByPlayer(target).getValue().equalsIgnoreCase("all")) {
        target.sendMessage(ChatColor.GRAY + "From " + Players.getName(sender) + ChatColor.GRAY + ": " + ChatColor.RESET + cmd.getJoinedStrings(0));
        sender.sendMessage(ChatColor.GRAY + "To " + Players.getName(target) + ChatColor.GRAY + ": " + ChatColor.RESET + cmd.getJoinedStrings(0));
        if (Settings.getSettingByName("PrivateMessageSounds") == null || Settings.getSettingByName("PrivateMessageSounds").getValueByPlayer(target).getValue().equalsIgnoreCase("on")) {
            target.playSound(target.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2F);
        }
        target.setMetadata("reply", new FixedMetadataValue(Cardinal.getInstance(), sender));
    } else {
        sender.sendMessage(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_DISABLED_PMS, Players.getName(target) + ChatColor.RED).getMessage(ChatUtil.getLocale(sender)));
    }
}
 
Example 16
@EventHandler(ignoreCancelled = true)
public void onSandCannon(EntityChangeBlockEvent event) {
    BukkitEntity entity = new BukkitEntity(event.getEntity());
    if (manager.isPlotWorld(entity) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
        if (event.getTo().equals(Material.AIR)) {
            entity.setMetadata("plotFallBlock", new FixedMetadataValue(plugin, event.getBlock().getLocation()));
        } else {
            List<MetadataValue> values = entity.getMetadata("plotFallBlock");

            if (!values.isEmpty()) {

                org.bukkit.Location spawn = (org.bukkit.Location) (values.get(0).value());
                org.bukkit.Location createdNew = event.getBlock().getLocation();

                if (spawn.getBlockX() != createdNew.getBlockX() || spawn.getBlockZ() != createdNew.getBlockZ()) {
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
Example 17
Source Project: CardinalPGM   Source File: InvisibleBlock.java    License: MIT License 6 votes vote down vote up
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    final Chunk chunk = event.getChunk();
    Bukkit.getScheduler().runTask(GameHandler.getGameHandler().getPlugin(), new Runnable() {
        @Override
        public void run() {
            for (Block block36 : chunk.getBlocks(Material.getMaterial(36))) {
                block36.setType(Material.AIR);
                block36.setMetadata("block36", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
            }
            for (Block door : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) {
                if (door.getRelative(BlockFace.DOWN).getType() != Material.IRON_DOOR_BLOCK
                        && door.getRelative(BlockFace.UP).getType() != Material.IRON_DOOR_BLOCK)
                    door.setType(Material.BARRIER);
            }
        }
    });
}
 
Example 18
Source Project: ce   Source File: PricklyBlock.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean effect(Event event, Player player) {
	if(event instanceof BlockPlaceEvent) {
		BlockPlaceEvent e = (BlockPlaceEvent) event;
		Block b = e.getBlock();
		b.setMetadata("ce.mine", new FixedMetadataValue(main, getOriginalName()));
		String coord = b.getX() + " " + b.getY() + " " + b.getZ();
		b.getRelative(0,1,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(0,-1,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(1,0,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(0,0,1).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(0,0,-1).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
		b.getRelative(-1,0,0).setMetadata("ce.mine.secondary", new FixedMetadataValue(main, coord));
	} else if(event instanceof PlayerMoveEvent) {
		if(!player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPotionEffect(PotionEffectType.CONFUSION)) {
			player.damage(Damage);
			player.sendMessage(ChatColor.DARK_GREEN + "A nearbly Block is hurting you!");
			player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, NauseaDuration, NauseaLevel));
		}
	}
	return false;
}
 
Example 19
Source Project: ce   Source File: Bandage.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private void heal(final Player p) {
	p.sendMessage(ChatColor.GREEN + "The bandage covers your wounds.");
	p.setMetadata("ce." + getOriginalName(), new FixedMetadataValue(main, ChatColor.RED + "You are already using a bandage!"));
	if(p.hasMetadata("ce.bleed")) 
		p.removeMetadata("ce.bleed", main);
	new BukkitRunnable() {
		int localCounter = TotalHealTime;
		@Override
		public void run() {
			if(!p.isDead() && localCounter != 0) {
				if(((Damageable) p).getHealth() == ((Damageable) p).getMaxHealth() && StopAtFullHealth) {
					p.sendMessage(ChatColor.GREEN + "Your wounds have fully recovered.");
					this.cancel();
				}
				if(((Damageable) p).getHealth() + healBursts <= ((Damageable) p).getMaxHealth())
					p.setHealth(((Damageable) p).getHealth() + healBursts);
				else
					p.setHealth(((Damageable) p).getMaxHealth());
			localCounter--;
			} else {
				p.sendMessage(ChatColor.GREEN + "The bandage has recovered some of your wounds.");
				this.cancel();
			}
		}
	}.runTaskTimer(main, 0l, 20l);
}
 
Example 20
Source Project: ce   Source File: IceAspect.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private HashMap<Block, String> getIgloo(Location start, int size, Player p) {
    HashMap<Block, String> list = new HashMap<Block, String>();
    int bx = start.getBlockX();
    int by = start.getBlockY();
    int bz = start.getBlockZ();

    for (int x = bx - size; x <= bx + size; x++)
        for (int y = by - 1; y <= by + size; y++)
            for (int z = bz - size; z <= bz + size; z++) {
                double distancesquared = (bx - x) * (bx - x) + ((bz - z) * (bz - z)) + ((by - y) * (by - y));
                if (distancesquared < (size * size) && distancesquared >= ((size - 1) * (size - 1))) {
                    org.bukkit.block.Block b = new Location(start.getWorld(), x, y, z).getBlock();
                    if ((b.getType() == Material.AIR || (!b.getType().equals(Material.CARROT) && !b.getType().equals(Material.POTATO) && !b.getType().equals(Material.CROPS)
                            && !b.getType().toString().contains("SIGN") && !b.getType().isSolid())) && Tools.checkWorldGuard(b.getLocation(), p, "PVP", false)) {
                        list.put(b, b.getType().toString() + " " + b.getData());
                        b.setType(Material.ICE);
                        b.setMetadata("ce.Ice", new FixedMetadataValue(getPlugin(), null));
                    }
                }
            }
    return list;
}
 
Example 21
Source Project: ce   Source File: Tools.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void applyBleed(final Player target, final int bleedDuration) {
    target.sendMessage(ChatColor.RED + "You are Bleeding!");
    target.setMetadata("ce.bleed", new FixedMetadataValue(Main.plugin, null));
    new BukkitRunnable() {

        int seconds = bleedDuration;

        @Override
        public void run() {
            if (seconds >= 0) {
                if (!target.isDead() && target.hasMetadata("ce.bleed")) {
                    target.damage(1 + (((Damageable) target).getHealth() / 15));
                    seconds--;
                } else {
                    target.removeMetadata("ce.bleed", Main.plugin);
                    this.cancel();
                }
            } else {
                target.removeMetadata("ce.bleed", Main.plugin);
                target.sendMessage(ChatColor.GREEN + "You have stopped Bleeding!");
                this.cancel();
            }
        }
    }.runTaskTimer(Main.plugin, 0l, 20l);

}
 
Example 22
@Override
public boolean execute(CommandSender sender, List<String> args) {
    Player player = (Player) sender;
    if (!Main.isHologramsEnabled()) {
        player.sendMessage(i18n("holo_not_enabled"));
    } else {
        player.setMetadata("bw-remove-holo", new FixedMetadataValue(Main.getInstance(), true));
        player.sendMessage(i18n("click_to_holo_for_remove"));
    }
    return true;
}
 
Example 23
Source Project: TrMenu   Source File: ActionSetShape.java    License: MIT License 5 votes vote down vote up
@Override
public void onExecute(Player player) {
    Menu menu = TrMenuAPI.getMenu(player);
    int shapeIndex = NumberUtils.toInt(getContent(player), -1);
    if (menu != null && menu.getRows().size() > 1 && shapeIndex != menu.getShape(player)) {
        player.setMetadata("TrMenu.Force-Close", new FixedMetadataValue(TrMenu.getPlugin(), "Close"));
        menu.open(player, shapeIndex, true, ArgsCache.getPlayerArgs(player));
        player.removeMetadata("TrMenu.Force-Close", TrMenu.getPlugin());
    }
}
 
Example 24
Source Project: TrMenu   Source File: ActionForceClose.java    License: MIT License 5 votes vote down vote up
@Override
public void onExecute(Player player) {
    Bukkit.getScheduler().runTask(TrMenu.getPlugin(), () -> {
        player.setMetadata("TrMenu.Force-Close", new FixedMetadataValue(TrMenu.getPlugin(), "Close"));
        player.closeInventory();
        player.removeMetadata("TrMenu.Force-Close", TrMenu.getPlugin());
    });
}
 
Example 25
@Override
public boolean execute(CommandSender sender, List<String> args) {
    Player player = (Player) sender;
    if (!Main.isHologramsEnabled()) {
        player.sendMessage(i18n("holo_not_enabled"));
    } else {
        player.setMetadata("bw-remove-holo", new FixedMetadataValue(Main.getInstance(), true));
        player.sendMessage(i18n("click_to_holo_for_remove"));
    }
    return true;
}
 
Example 26
Source Project: ActionHealth   Source File: McMMOSupport.java    License: MIT License 5 votes vote down vote up
public String getName(MetadataValue metadataValue) {
    /*if (metadataValue instanceof OldName) {
        OldName oldName = (OldName) metadataValue;
        return oldName.asString();
    }*/

    FixedMetadataValue fixedMetadataValue = (FixedMetadataValue) metadataValue;
    return fixedMetadataValue.asString();
}
 
Example 27
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    match.player(event.getActor()).ifPresent(shooter -> {
        final Projectile projectile = event.getEntity();
        projectile.setMetadata(TRAIL_META, new FixedMetadataValue(PGM.get(), shooter.getParty().getFullColor()));
        // Set critical metadata to false in order to remove default particle trail.
        // The metadata will be restored just before the arrow hits something.
        if(projectile instanceof Arrow) {
            final Arrow arrow = (Arrow) projectile;
            arrow.setMetadata(CRITICAL_META, new FixedMetadataValue(PGM.get(), arrow.isCritical()));
            arrow.setCritical(false);
        }
    });
}
 
Example 28
private ListenableFuture<?> quitFuture(Player player) {
    if(player.isOnline()) {
        final SettableFuture<?> future = SettableFuture.create();
        player.setMetadata(METADATA_KEY, new FixedMetadataValue(plugin, future));
        return future;
    } else {
        return Futures.immediateFuture(null);
    }
}
 
Example 29
private void set(Player player, String key, @Nullable Boolean value) {
    if(value != null) {
        player.setMetadata(key, new FixedMetadataValue(plugin, value));
    } else {
        player.removeMetadata(key, plugin);
    }
}
 
Example 30
Source Project: CardinalPGM   Source File: Fireworks.java    License: MIT License 5 votes vote down vote up
public static Firework spawnFirework(Location loc, FireworkEffect effect, int power) {
    Firework firework = loc.getWorld().spawn(loc, Firework.class);
    FireworkMeta fireworkMeta = firework.getFireworkMeta();
    fireworkMeta.addEffect(effect);
    fireworkMeta.setPower(power);
    firework.setFireworkMeta(fireworkMeta);
    firework.setMetadata(FIREWORK_METADATA, new FixedMetadataValue(Cardinal.getInstance(), true));
    return firework;
}