Java Code Examples for org.bukkit.Effect

The following are top voted examples for showing how to use org.bukkit.Effect. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: UltraCore   File: Events.java   View source code 6 votes vote down vote up
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
	Player player = (Player) event.getWhoClicked();
	ItemStack is = event.getCurrentItem();
	if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
		if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
			event.setCancelled(true);
               for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
               Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
               Location location = player.getLocation();
               if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                   player.closeInventory();
                   player.teleport(targetPlayer);
           		player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
           		player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
           		player.playEffect(location, Effect.ENDER_SIGNAL, 1);
           		targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
               }
               }
           }
	}
}
 
Example 2
Project: UltraCore   File: Events.java   View source code 6 votes vote down vote up
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
	Player player = (Player) event.getWhoClicked();
	ItemStack is = event.getCurrentItem();
	if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
		if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
			event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
                    player.closeInventory();
                    targetPlayer.teleport(player);
            		player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
            		player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
            		player.playEffect(location, Effect.ENDER_SIGNAL, 1);
            		targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);	
                }
               }
           }
       }
   }
 
Example 3
Project: Uranium   File: CraftWorld.java   View source code 6 votes vote down vote up
public <T> void playEffect(Location loc, Effect effect, T data, int radius) {
    if (data != null) {
        Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
    } else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
    }

    if (data != null && data.getClass().equals( org.bukkit.material.MaterialData.class )) {
        org.bukkit.material.MaterialData materialData = (org.bukkit.material.MaterialData) data;
        Validate.isTrue( materialData.getItemType().isBlock(), "Material must be block" );
        spigot().playEffect( loc, effect, materialData.getItemType().getId(), materialData.getData(), 0, 0, 0, 1, 1, radius );
    } else {
        int dataValue = data == null ? 0 : CraftEffect.getDataValue( effect, data );
        playEffect( loc, effect, dataValue, radius );
    }
}
 
Example 4
Project: Uranium   File: CraftJukebox.java   View source code 6 votes vote down vote up
@Override
public void setPlaying(Material record) {
    if (record == null || CraftMagicNumbers.getItem(record) == null) {
        record = Material.AIR;
        jukebox.func_145857_a(null);
    } else {
        jukebox.func_145857_a(new ItemStack(CraftMagicNumbers.getItem(record), 1));
    }
    jukebox.markDirty();
    if (record == Material.AIR) {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 0, 3);
    } else {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 1, 3);
    }
    world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
 
Example 5
Project: chaoticWeapons   File: Core.java   View source code 6 votes vote down vote up
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (cmd.getName().equalsIgnoreCase("epicweapon")) {
		if(sender instanceof Player){
			if(sender.hasPermission("chaoticweapons.create") || sender.hasPermission("*")){
				Player player = (Player) sender;
				if (args.length != 0) {
					player.sendMessage(e + "Command Syntax: too many paremeters");
					player.sendMessage(ChatColor.GREEN + "[FIX]: " + ChatColor.BLUE + "type /epicweapon");
				} else {
					player.openInventory(selectEffect());
					player.getWorld().playEffect(player.getLocation(), Effect.POTION_BREAK, 0);
				}
			}else{
				sender.sendMessage(e + "Permission: You dont have permissions");
			}
		}else{
			sender.sendMessage(ChatColor.RED + "Only players can use this!");
		}
		return true;
	}
	return false;
}
 
Example 6
Project: ProjectAres   File: BloodMatchModule.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
        if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
            EntityUtils.entities(match.getWorld(), Player.class)
                 .filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
                 .forEach(player -> {
                     if(event instanceof EntityDamageByEntityEvent) {
                         player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
                     } else {
                         player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
                     }
                 });
        }
    }
}
 
Example 7
Project: ProjectAres   File: BlitzMatchModule.java   View source code 6 votes vote down vote up
private void handleElimination(final MatchPlayer player) {
    if (!eliminatedPlayers.add(player.getBukkit().getUniqueId())) return;

    World world = player.getMatch().getWorld();
    Location death = player.getBukkit().getLocation();

    double radius = 0.1;
    int n = 8;
    for(int i = 0; i < 6; i++) {
        double angle = 2 * Math.PI * i / n;
        Location base = death.clone().add(new Vector(radius * Math.cos(angle), 0, radius * Math.sin(angle)));
        for(int j = 0; j <= 8; j++) {
            world.playEffect(base, Effect.SMOKE, j);
        }
    }
    checkEnd();
}
 
Example 8
Project: Hub   File: DeveloperRoomParkour.java   View source code 6 votes vote down vote up
@Override
public void removePlayer(Player player)
{
    super.removePlayer(player);

    this.expected.remove(player.getUniqueId());
    player.setResourcePack("http://resources.samagames.net/samareset.zip");
    player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0);
}
 
Example 9
Project: AmazingEgss   File: l.java   View source code 6 votes vote down vote up
/** @EVENTS **/

    @EventHandler

    public void tirarhuevo(PlayerEggThrowEvent e){

        if (e.isHatching()){
            Location loc = e.getPlayer().getLocation();

            for(int i = 0; i <360; i+=5) {
                Location particleloc = loc;
                particleloc.setZ(particleloc.getZ() + Math.cos(i) * 0.6);
                particleloc.setX(particleloc.getX() + Math.sin(i) * 0.5);
                particleloc.setY(particleloc.getY() + 0.05);
                loc.getWorld().playEffect(particleloc, Effect.valueOf(plugin.particle), 51);
            }

            Location location = e.getPlayer().getLocation();
            e.getPlayer().playSound(location, Sound.valueOf(plugin.sound), 1, 1);
        }
    }
 
Example 10
Project: ExoticGarden   File: PlantsListener.java   View source code 6 votes vote down vote up
public void dropFruitFromTree(Block block) {
	for (int x = -1; x < 2; x++) {
		for (int y = -1; y < 2; y++) {
			for (int z = -1; z < 2; z++) { //inspect a cube at the reference
				Block drop = block.getRelative(x, y, z);
				SlimefunItem check = BlockStorage.check(drop);
				if (check != null) {
					for (Tree tree: ExoticGarden.trees) {
						if (check.getName().equalsIgnoreCase(tree.fruit)) {
							BlockStorage.clearBlockInfo(drop);
							ItemStack fruits = check.getItem();
							drop.getWorld().playEffect(drop.getLocation(), Effect.STEP_SOUND, Material.LEAVES);
							drop.getWorld().dropItemNaturally(drop.getLocation(), fruits);
							drop.setType(Material.AIR);
						}
					}
				}
			}
		}
	}
}
 
Example 11
Project: WildernessTp   File: CheckConfig.java   View source code 6 votes vote down vote up
public boolean checkParticle(){
    if(wild.getConfig().getBoolean("DoParticle")) {
        try {
            String[] tmp = Bukkit.getVersion().split("MC: ");
            String version = tmp[tmp.length - 1].substring(0, 3);
            Particle particle;
            Effect effect;
            if (version.equals("1.9") || version.equals("1.1"))
                particle = Particle.valueOf(wild.getConfig().getString("Particle").toUpperCase());
            else
                effect = Effect.valueOf(wild.getConfig().getString("Particle").toUpperCase());
        } catch (IllegalArgumentException e) {
            return false;
        }
    }else
        return true;
    return true;
}
 
Example 12
Project: ThermosRebased   File: CraftWorld.java   View source code 6 votes vote down vote up
public <T> void playEffect(Location loc, Effect effect, T data, int radius) {
    if (data != null) {
        Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
    } else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
    }

    if (data != null && data.getClass().equals( org.bukkit.material.MaterialData.class )) {
        org.bukkit.material.MaterialData materialData = (org.bukkit.material.MaterialData) data;
        Validate.isTrue( materialData.getItemType().isBlock(), "Material must be block" );
        spigot().playEffect( loc, effect, materialData.getItemType().getId(), materialData.getData(), 0, 0, 0, 1, 1, radius );
    } else {
        int dataValue = data == null ? 0 : CraftEffect.getDataValue( effect, data );
        playEffect( loc, effect, dataValue, radius );
    }
}
 
Example 13
Project: ThermosRebased   File: CraftJukebox.java   View source code 6 votes vote down vote up
@Override
public void setPlaying(Material record) {
    if (record == null || CraftMagicNumbers.getItem(record) == null) {
        record = Material.AIR;
        jukebox.func_145857_a(null);
    } else {
        jukebox.func_145857_a(new ItemStack(CraftMagicNumbers.getItem(record), 1));
    }
    jukebox.markDirty();
    if (record == Material.AIR) {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 0, 3);
    } else {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 1, 3);
    }
    world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
 
Example 14
Project: CS-CoreLib   File: BlockBreaker.java   View source code 6 votes vote down vote up
public static void breakBlock(Player p, Block b, List<ItemStack> drops, boolean check) {
	boolean allowed = true;
	
	if (check) {
		BlockBreakEvent event = new BlockBreakEvent(b, p);
		Bukkit.getServer().getPluginManager().callEvent(event);
		allowed = !event.isCancelled();
	}
	
	if (allowed) {
		for (ItemStack drop : drops) {
			b.getWorld().dropItemNaturally(b.getLocation(), drop);
	    }
	    if (check) b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
	    b.setType(Material.AIR);
	}
}
 
Example 15
Project: QuestManager   File: QuestPlayer.java   View source code 6 votes vote down vote up
private void castSpell(Spell spell) {
	if (!getPlayer().isOnline()) {
		return;
	}
	
	if (spell == null) {
		return;
	}
	
	if (!getPlayer().getPlayer().getGameMode().equals(GameMode.CREATIVE) && 
			mp < spell.getCost()) {
		getPlayer().getPlayer().playSound(getPlayer().getPlayer().getLocation(), Sound.BLOCK_WATERLILY_PLACE, 1.0f, 0.5f);
		return;
	}
	
	if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getMagicEnabled()) {
		return;
	}
	
	new ChargeEffect(Effect.WITCH_MAGIC)
		.play(getPlayer().getPlayer(), getPlayer().getPlayer().getLocation());
	
	addMP(-spell.getCost());
	spell.cast(this);
}
 
Example 16
Project: QuestManager   File: SpellProjectile.java   View source code 6 votes vote down vote up
public SpellProjectile(TargetSpell source, MagicUser caster, Location start, Vector direction,
		double speed, int maxDistance, Effect paceEffect) {
	this.sourceSpell = source;
	this.distance = 0;
	this.maxDistance = maxDistance;
	this.location = start.clone();
	this.direction = direction;
	this.caster = caster;
	this.effect = paceEffect;
	
	double rate = 20 / speed;
	
	if (rate >= 1) {
		perTick = 1;
		delay = (int) Math.round(rate);
	} else {
		delay = 1;
		perTick = (int) Math.round(1 / rate);
	}
	
	Bukkit.getScheduler().runTaskLater(QuestManagerPlugin.questManagerPlugin, this, delay);
}
 
Example 17
Project: QuestManager   File: ChargeAction.java   View source code 6 votes vote down vote up
public ChargeAction(MenuAction action, QuestPlayer player, Effect effect, Sound sound, boolean canMove, 
		boolean canGetHit, boolean canChangeItems, double chargingTime) {
	if (!player.getPlayer().isOnline()) {
		return;
	}
	
	this.action = action;
	this.canMove = canMove;
	this.canGetHit = canGetHit;
	this.canChangeItems = canChangeItems;
	this.player = player;
	this.effect = new AuraEffect(effect);
	this.effect.play(player.getEntity());
	
	player.getEntity().getWorld().playSound(player.getEntity().getLocation(), sound, 1, 1);

	Bukkit.getPluginManager().registerEvents(this, QuestManagerPlugin.questManagerPlugin);
	Alarm.getScheduler().schedule(this, 0, chargingTime);
}
 
Example 18
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeSheild(final BlockPlaceEvent e,final float delay){//充能动画+延时
    float speed=e.getPlayer().getWalkSpeed();
    //System.out.print(e.getPlayer().getWalkSpeed());
    e.getPlayer().setWalkSpeed(0.05f);
    new BukkitRunnable(){
        float time = delay;  // delay秒
        @Override
        public void run() {               
            e.getPlayer().setExp(1-time/delay);//充能进度条
            time=time-0.1f;
            for(float i=0; i<delay-time;i=i+0.01f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.PORTAL, 0);
            }
            if(time <= 0){
                CreatePulse(e);
                e.getPlayer().setExp(0.0F);
                e.getPlayer().setWalkSpeed(0.2f);
                //System.out.print("调回来了");
                cancel();  // 终止线程
                return;
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 1L);
}
 
Example 19
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeTNT(final BlockPlaceEvent e){//问题找到了,双重TNT会有两次加速。。
    float speed=e.getPlayer().getWalkSpeed();
    if(1.5f*speed<=1){
        e.getPlayer().setWalkSpeed(1.5f*speed);
    }
    else{
        e.getPlayer().setWalkSpeed(1f);
    }
    new BukkitRunnable(){
        float time=TNTdelay;
        @Override
        public void run(){
            time=time-0.1f;
            e.getPlayer().setExp(1-(time/TNTdelay));
            for(float i=0;i<TNTdelay-time;i=i+0.1f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.FLAME, (int)i);//随便放点火花啥子的庆祝庆祝,时间越短越多
            }
            if(time<=0) {
                e.getPlayer().setWalkSpeed(0.2f);
                Explode(e);
                cancel();
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 2L);
    //this.Explode(e);
}
 
Example 20
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeSheild(final BlockPlaceEvent e,final float delay){//充能动画+延时
    //float speed=e.getPlayer().getWalkSpeed();
    //System.out.print(e.getPlayer().getWalkSpeed());
    e.getPlayer().setWalkSpeed(0.05f);
    new BukkitRunnable(){
        float time = delay;  // delay秒
        @Override
        public void run() {               
            e.getPlayer().setExp(1-time/delay);//充能进度条
            time=time-0.1f;
            for(float i=0; i<delay-time;i=i+0.01f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.PORTAL, 0);
            }
            if(time <= 0){
                CreatePulse(e);
                e.getPlayer().setExp(0.0F);
                e.getPlayer().setWalkSpeed(0.2f);
                //System.out.print("调回来了");
                cancel();  // 终止线程
                return;
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 1L);
}
 
Example 21
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeTNT(final BlockPlaceEvent e){//问题找到了,双重TNT会有两次加速。。
    float speed=e.getPlayer().getWalkSpeed();
    if(1.5f*speed<=1){
        e.getPlayer().setWalkSpeed(1.5f*speed);
    }
    else{
        e.getPlayer().setWalkSpeed(1f);
    }
    new BukkitRunnable(){
        float time=TNTdelay;
        @Override
        public void run(){
            time=time-0.1f;
            e.getPlayer().setExp(1-(time/TNTdelay));
            for(float i=0;i<TNTdelay-time;i=i+0.1f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.FLAME, (int)i);//随便放点火花啥子的庆祝庆祝,时间越短越多
            }
            if(time<=0) {
                e.getPlayer().setWalkSpeed(0.2f);
                Explode(e);
                cancel();
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 2L);
    //this.Explode(e);
}
 
Example 22
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeSheild(final BlockPlaceEvent e,final float delay){//充能动画+延时
    //float speed=e.getPlayer().getWalkSpeed();
    //System.out.print(e.getPlayer().getWalkSpeed());
    e.getPlayer().setWalkSpeed(0.05f);
    new BukkitRunnable(){
        float time = delay;  // delay秒
        @Override
        public void run() {               
            e.getPlayer().setExp(1-time/delay);//充能进度条
            time=time-0.1f;
            for(float i=0; i<delay-time;i=i+0.01f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.PORTAL, 0);
            }
            if(time <= 0){
                CreatePulse(e);
                e.getPlayer().setExp(0.0F);
                e.getPlayer().setWalkSpeed(0.2f);
                //System.out.print("调回来了");
                cancel();  // 终止线程
                return;
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 1L);
}
 
Example 23
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeTNT(final BlockPlaceEvent e){//问题找到了,双重TNT会有两次加速。。
    float speed=e.getPlayer().getWalkSpeed();
    if(1.5f*speed<=1){
        e.getPlayer().setWalkSpeed(1.5f*speed);
    }
    else{
        e.getPlayer().setWalkSpeed(1f);
    }
    new BukkitRunnable(){
        float time=TNTdelay;
        @Override
        public void run(){
            time=time-0.1f;
            e.getPlayer().setExp(1-(time/TNTdelay));
            for(float i=0;i<TNTdelay-time;i=i+0.1f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.FLAME, (int)i);//随便放点火花啥子的庆祝庆祝,时间越短越多
            }
            if(time<=0) {
                e.getPlayer().setWalkSpeed(0.2f);
                Explode(e);
                cancel();
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 2L);
    //this.Explode(e);
}
 
Example 24
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeSheild(final BlockPlaceEvent e,final float delay){//充能动画+延时
    float speed=e.getPlayer().getWalkSpeed();
    //System.out.print(e.getPlayer().getWalkSpeed());
    e.getPlayer().setWalkSpeed(0.05f);
    new BukkitRunnable(){
        float time = delay;  // delay秒
        @Override
        public void run() {               
            e.getPlayer().setExp(1-time/delay);//充能进度条
            time=time-0.1f;
            for(float i=0; i<delay-time;i=i+0.01f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.PORTAL, 0);
            }
            if(time <= 0){
                CreatePulse(e);
                e.getPlayer().setExp(0.0F);
                e.getPlayer().setWalkSpeed(0.2f);
                //System.out.print("调回来了");
                cancel();  // 终止线程
                return;
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 1L);
}
 
Example 25
Project: CraftPlugins   File: EffectExec.java   View source code 6 votes vote down vote up
public void ChargeTNT(final BlockPlaceEvent e){//问题找到了,双重TNT会有两次加速。。
    float speed=e.getPlayer().getWalkSpeed();
    if(1.5f*speed<=1){
        e.getPlayer().setWalkSpeed(1.5f*speed);
    }
    else{
        e.getPlayer().setWalkSpeed(1f);
    }
    new BukkitRunnable(){
        float time=TNTdelay;
        @Override
        public void run(){
            time=time-0.1f;
            e.getPlayer().setExp(1-(time/TNTdelay));
            for(float i=0;i<TNTdelay-time;i=i+0.1f){
                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.FLAME, (int)i);//随便放点火花啥子的庆祝庆祝,时间越短越多
            }
            if(time<=0) {
                e.getPlayer().setWalkSpeed(0.2f);
                Explode(e);
                cancel();
            }
        }
    }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 2L);
    //this.Explode(e);
}
 
Example 26
Project: Skellett   File: BlockConstructor.java   View source code 6 votes vote down vote up
@SuppressWarnings("deprecation")
public void generateLayer(Location start, boolean effect) {
	int skip = 0;
	int rowZ = 0;
	int rowY = 0;
	for (int i = 0; i < layer.length(); i++) {
		char character = layer.charAt(i);
		if (character == ':' || character == ',') {
			rowY ++;
			skip = i + 1;
		}
		if (character == ';' || character == '.') {
			rowZ ++;
			skip = i + 1;
		} else {
			Block block = start.getWorld().getBlockAt(start.getBlockX() + i - skip, start.getBlockY() + rowY, start.getBlockZ() + rowZ);
			if (chars.containsKey(character)) {
				block.setType(chars.get(character));
				if (effect) {
					block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
				}
			}
		}
	}
}
 
Example 27
Project: UltraCore   File: Tphere.java   View source code 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (sender instanceof ConsoleCommandSender) {
		return true;
	}
	Player player = (Player) sender;
	Location location = player.getLocation();
	if (label.equalsIgnoreCase("tphere")) {
		if (!(args.length == 0)) {
			if (args.length == 0) {
				player.sendMessage(ChatColor.RED + "Please specify the player you want to teleport to or use /teleport help for more info.");
				TeleportHereMenu.newInventory(sender);
				return true;
			}
			if (!sender.hasPermission("core.tp")) {
				player.sendMessage(ChatColor.RED + "Sorry, you need core.tp permission to execute /tphere.");
				return true;
			}
			if (args[0].equals(player.getName())) {
				player.sendMessage(ChatColor.RED + "Lol, you cannot teleport to yourself dummy.");
				return true;				
			}
			Player target1 = Bukkit.getServer().getPlayer(args[1]);
			if (target1 == null) {
				player.sendMessage(ChatColor.RED + "Can't find user specified.");
				return true;	
			}
			target1.teleport(player);
			player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + target1.getDisplayName() + ChatColor.YELLOW + " to you!");
			player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
			player.playEffect(location, Effect.ENDER_SIGNAL, 1);
			target1.playEffect(location, Effect.ENDER_SIGNAL, 1);
			return true;
		}
	}
return false;	
}
 
Example 28
Project: UltraCore   File: Tppos.java   View source code 5 votes vote down vote up
@SuppressWarnings("unused")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (sender instanceof ConsoleCommandSender) {
		return true;
	}
	Player player = (Player) sender;
	Location location = player.getLocation();
	if (label.equalsIgnoreCase("tppos")) {
		if (args.length == 0) {
			player.sendMessage(ChatColor.RED + "Please specify the location you want to teleport to or use /teleport help for more info.");
			return true;
		}
		if (!sender.hasPermission("core.tp")) {
			player.sendMessage(ChatColor.RED + "Sorry, you need core.tp permission to execute /teleport.");
			return true;
		}
		Location loc = new Location(player.getLocation().getWorld(), Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
		if (loc == null) {
			player.sendMessage(ChatColor.RED + "Location invalid or not typed correctly do /teleport help or contact an admin for help");
			return true;
		}
			player.teleport(loc);
			player.sendMessage(ChatColor.YELLOW + "You have been teleported to: " + ChatColor.GREEN + "X: " + args[0] + ", Y: " + args[1] + ", Z: " + args[2]);
			player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
			player.playEffect(location, Effect.ENDER_SIGNAL, 1);
			return true;
	}
return false;	
}
 
Example 29
Project: UltraCore   File: Tphere.java   View source code 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        return true;
    }
    Player player = (Player) sender;
    Location location = player.getLocation();
    if (label.equalsIgnoreCase("tphere")) {
        if (!(args.length == 0)) {
            if (args.length == 0) {
                player.sendMessage(ChatColor.RED + "Please specify the player you want to teleport to or use /teleport help for more info.");
                TeleportHereMenu.newInventory(sender);
                return true;
            }
            if (!sender.hasPermission("core.tp")) {
                player.sendMessage(ChatColor.RED + "Sorry, you need core.tp permission to execute /tphere.");
                return true;
            }
            if (args[0].equals(player.getName())) {
                player.sendMessage(ChatColor.RED + "Lol, you cannot teleport to yourself dummy.");
                return true;
            }
            Player target1 = Bukkit.getServer().getPlayer(args[1]);
            if (target1 == null) {
                player.sendMessage(ChatColor.RED + "Can't find user specified.");
                return true;
            }
            target1.teleport(player);
            player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + target1.getDisplayName() + ChatColor.YELLOW + " to you!");
            player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
            player.playEffect(location, Effect.ENDER_SIGNAL, 1);
            target1.playEffect(location, Effect.ENDER_SIGNAL, 1);
            return true;
        }
    }
    return false;
}
 
Example 30
Project: UltraCore   File: Tppos.java   View source code 5 votes vote down vote up
@SuppressWarnings("unused")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        return true;
    }
    Player player = (Player) sender;
    Location location = player.getLocation();
    if (label.equalsIgnoreCase("tppos")) {
        if (args.length == 0) {
            player.sendMessage(ChatColor.RED + "Please specify the location you want to teleport to or use /teleport help for more info.");
            return true;
        }
        if (!sender.hasPermission("core.tp")) {
            player.sendMessage(ChatColor.RED + "Sorry, you need core.tp permission to execute /teleport.");
            return true;
        }
        Location loc = new Location(player.getLocation().getWorld(), Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
        if (loc == null) {
            player.sendMessage(ChatColor.RED + "Location invalid or not typed correctly do /teleport help or contact an admin for help");
            return true;
        }
        player.teleport(loc);
        player.sendMessage(ChatColor.YELLOW + "You have been teleported to: " + ChatColor.GREEN + "X: " + args[0] + ", Y: " + args[1] + ", Z: " + args[2]);
        player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
        player.playEffect(location, Effect.ENDER_SIGNAL, 1);
        return true;
    }
    return false;
}
 
Example 31
Project: Scorch   File: ObsidianToLava.java   View source code 5 votes vote down vote up
@Override
public void run(){
    if(locations.isEmpty()) return;
    for(Location loc : locations.keySet()){
        int x = locations.get(loc) - 1;
        locations.remove(loc);
        locations.put(loc, x);
        if (locations.get(loc) <= 0){
            Main.getMainWorld().playEffect(loc, Effect.SMOKE, 31);
            Main.getMainWorld().getBlockAt(loc).setType(Material.STATIONARY_LAVA);
            locations.remove(loc);
        }
    }
}
 
Example 32
Project: Absorption   File: ArenaBlock.java   View source code 5 votes vote down vote up
public void colorBlock(TeamColor color) {
	this.color = color;
	if(color == null) {
		restoreBlock();
		return;
	}
	BLOCK.setType(color.getMaterial());
	BLOCK.setData((byte) color.getData());
	
	// TODO Improvements to do in effects (ae: effects on block sides)
	BLOCK.getWorld().playEffect(BLOCK.getLocation().add(Math.random(), 1, Math.random()), Effect.SPLASH, 0);
	for(int i = 0; i < 5; i++)
		ParticleEffect.REDSTONE.display(color.getParticleColor(), BLOCK.getLocation().add(Math.random(), 1, Math.random()), 20);
}
 
Example 33
Project: Slimefun4-Chinese-Version   File: JetBootsTask.java   View source code 5 votes vote down vote up
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        float cost = 0.075F;
        float charge = ItemEnergy.getStoredEnergy(p.getInventory().getBoots());
        double accuracy = Double.valueOf((new DecimalFormat("##.##")).format(speed - 0.69999999999999996D).replace(",", ".")).doubleValue();
        if(charge >= cost)
        {
            p.getInventory().setBoots(ItemEnergy.chargeItem(p.getInventory().getBoots(), -cost));
            me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 0.25F, 1.0F);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
            p.setFallDistance(0.0F);
            double gravity = 0.040000000000000001D;
            double offset = SlimefunStartup.chance(100, 50) ? accuracy : -accuracy;
            Vector vector = new Vector(p.getEyeLocation().getDirection().getX() * speed + offset, gravity, p.getEyeLocation().getDirection().getZ() * speed - offset);
            p.setVelocity(vector);
        } else
        {
            Bukkit.getScheduler().cancelTask(id);
        }
    }
}
 
Example 34
Project: Slimefun4-Chinese-Version   File: JetpackTask.java   View source code 5 votes vote down vote up
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        float cost = 0.08F;
        float charge = ItemEnergy.getStoredEnergy(p.getInventory().getChestplate());
        if(charge >= cost)
        {
            p.getInventory().setChestplate(ItemEnergy.chargeItem(p.getInventory().getChestplate(), -cost));
            me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.25F, 1.0F);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
            p.setFallDistance(0.0F);
            Vector vector = new Vector(0, 1, 0);
            vector.multiply(thrust);
            vector.add(p.getEyeLocation().getDirection().multiply(0.2F));
            p.setVelocity(vector);
        } else
        {
            Bukkit.getScheduler().cancelTask(id);
        }
    }
}
 
Example 35
Project: ProjectAres   File: Uncarried.java   View source code 5 votes vote down vote up
@Override
public void tickLoaded() {
    super.tickLoaded();

    if(this.particleClock % 10 == 0) {
        this.flag.getMatch().getWorld().playEffect(this.getLocation().clone().add(0, 1, 0),
                                                   Effect.PORTAL,
                                                   0, 0,
                                                   0, 0, 0,
                                                   1, 8, 64);
    }
}
 
Example 36
Project: KingdomFactions   File: Leap.java   View source code 5 votes vote down vote up
@Override
public void execute(KingdomFactionsPlayer player) {

	noFallDamage.add(player.getName());

	double forwardPowerModifier = 1.5D;
	double upwardPowerModifier = forwardPowerModifier * 2.0D;
	double fwv = 2.0D;
	double uwv = 0.7D;

	Vector dir = player.getLocation().getDirection();

	dir.setY(0).normalize().multiply(fwv * forwardPowerModifier).setY(uwv * upwardPowerModifier);

	player.getPlayer().setVelocity(dir);

	final World w = player.getPlayer().getWorld();
	w.playSound(player.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);

	new BukkitRunnable() {
		int autoStopCount = 0;

		@SuppressWarnings("deprecation")
		public void run() {
			if ((this.autoStopCount <= 30) && (Leap.noFallDamage.contains(player.getName()))
					&& (Bukkit.getPlayer(player.getName()) != null)
					&& (!Bukkit.getPlayer(player.getName()).isOnGround())) {
				Player p = Bukkit.getPlayer((player.getName()));
				w.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 1);

				this.autoStopCount += 1;
			} else {
				if ((Leap.noFallDamage.contains(player.getName()))) {
					Leap.noFallDamage.remove(player.getName());
				}
				cancel();
			}
		}
	}.runTaskTimer(KingdomFactionsPlugin.getInstance(), 5L, 3L);
}
 
Example 37
Project: libtrails   File: Particle.java   View source code 5 votes vote down vote up
public Particle(Effect effect, int id, int data, Object offx,
                   Object offy, Object offz, Object particleCount,
                Object speed, int radius){
    this.effect = effect;
    this.id = id;
    this.data = data;

    this.speed = speed;
    this.particleCount = particleCount;
    this.radius = radius;

    this.offx = offx;
    this.offy = offy;
    this.offz = offz;
}
 
Example 38
Project: AlphaLibary   File: RectangleParticleForm.java   View source code 5 votes vote down vote up
public RectangleParticleForm(Effect effect, EffectData<?> effectData, Location location, String axis, double dense, double width, double lenght, boolean filled) {
    super(location, axis, dense, width, lenght, filled, null);

    if (effectData != null)
        Validate.isTrue(effect.getData() != null && effect.getData().isAssignableFrom(effectData.getDataValue().getClass()), "Wrong kind of effectData for this effect!");
    else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of effectData for this effect!");
        effectData = new EffectData<>(null);
    }

    EffectData<?> finalEffectData = effectData;

    setAction((p, loc) -> p.playEffect(loc, effect, finalEffectData.getDataValue()));
}
 
Example 39
Project: AlphaLibary   File: CircleParticleForm.java   View source code 5 votes vote down vote up
public CircleParticleForm(Effect effect, EffectData<?> effectData, Location location, String axis, double dense, double radius) {
    super(location, axis, dense, radius, null);

    if (effectData != null)
        Validate.isTrue(effect.getData() != null && effect.getData().isAssignableFrom(effectData.getDataValue().getClass()), "Wrong kind of effectData for this effect!");
    else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of effectData for this effect!");
        effectData = new EffectData<>(null);
    }

    EffectData<?> finalEffectData = effectData;

    setAction((p, loc) -> p.playEffect(loc, effect, finalEffectData.getDataValue()));
}
 
Example 40
Project: AlphaLibary   File: PolyParticleForm.java   View source code 5 votes vote down vote up
public PolyParticleForm(Effect effect, EffectData<?> effectData, Location location, double dense, Pair<Vector, Vector>... points) {
    super(location, dense, null, points);

    if (effectData != null)
        Validate.isTrue(effect.getData() != null && effect.getData().isAssignableFrom(effectData.getDataValue().getClass()), "Wrong kind of effectData for this effect!");
    else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of effectData for this effect!");
        effectData = new EffectData<>(null);
    }

    EffectData<?> finalEffectData = effectData;

    setAction((p, loc) -> p.playEffect(loc, effect, finalEffectData.getDataValue()));
}