下面列出了怎么用org.bukkit.metadata.FixedMetadataValue的API类实例代码及写法,或者点击链接到github查看源代码。
@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--------------------------------------------------");
}
@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);
}
}
}
}
@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);
}
}
}
@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()));
}
}
}
@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()));
}
}
}
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);
}
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);
}
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);
}
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);
}
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);
}
@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());
}
}
}
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);
}
@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);
}
@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()));
}
}
}
@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)));
}
}
@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);
}
}
}
}
}
@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);
}
}
});
}
@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;
}
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);
}
@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;
}
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);
}
@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;
}
@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());
}
}
@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());
});
}
@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;
}
public String getName(MetadataValue metadataValue) {
/*if (metadataValue instanceof OldName) {
OldName oldName = (OldName) metadataValue;
return oldName.asString();
}*/
FixedMetadataValue fixedMetadataValue = (FixedMetadataValue) metadataValue;
return fixedMetadataValue.asString();
}
@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);
}
});
}
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);
}
}
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);
}
}
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;
}