Potion Giving

Discussion in 'Plugin Development' started by Jaaakee224, Mar 18, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Jaaakee224

    So, if you know PizzaSpleef by Sethbling, you should know my concept.

    Pretty much, when you break a specific block, it gives all the other players that potion effect except the player who broke that block.

    Can anybody show me some example code?

    Here is what I have so far..
    Code:java
    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent e) {
    3. Block b = e.getBlock();
    4.  
    5. if(b.getType() == Material.REDSTONE_BLOCK) {
    6. e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5, 2));
    7.  
    8. if(b.getType() == Material.GLASS) {
    9. e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 5, 2));
    10.  
    11. if(b.getType() == Material.WOOD) {
    12. e.getPlayer().getInventory().addItem(new ItemStack(Material.MONSTER_EGG, 3, (short) 50));
    13.  
    14. if(b.getType() == Material.WOOL) {
    15. Wool wool = (Wool) b;
    16. if(wool.getColor() == DyeColor.GREEN) {
    17. e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10, (short) 10));
    18.  
    19. if(b.getType() == Material.SOUL_SAND) {
    20. e.getPlayer().getInventory().addItem(new ItemStack(Material.POTION, 4, (short) 16426));


    Thanks. :p
     
  2. Offline

    Wolfey

    Okay, first you're checking if it's a redstone block, then you're checking if it's glass... what?

    It's definitely gonna fail there.
     
  3. Offline

    Jaaakee224

    Wolfey Fixed, but do you know my main question?
     
  4. Offline

    Venexor

    I think he means this:
    Code:java
    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent e) {
    3. Block b = e.getBlock();
    4.  
    5. if(b.getType() == Material.REDSTONE_BLOCK) {
    6. e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5, 2));
    7. }
    8. else if(b.getType() == Material.GLASS) {
    9. e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 5, 2));
    10. }
    11.  
    12. else if(b.getType() == Material.WOOD) {
    13. e.getPlayer().getInventory().addItem(new ItemStack(Material.MONSTER_EGG, 3, (short) 50));
    14. }
    15.  
    16. else if(b.getType() == Material.WOOL) {
    17. Wool wool = (Wool) b;
    18. if(wool.getColor() == DyeColor.GREEN) {
    19. e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10, (short) 10));
    20. }
    21.  
    22. else if(b.getType() == Material.SOUL_SAND) {
    23. e.getPlayer().getInventory().addItem(new ItemStack(Material.POTION, 4, (short) 16426));
     
  5. Offline

    Jaaakee224

    Venexor Yes, I fixed that before.
     
  6. Offline

    Wolfey

    Jaaakee224 Run a for loop on all players in the game, check if the player != the players you are looping through, then add them a potion effect?
     
  7. Offline

    MooshViolet

    have you registered events?
     
  8. Offline

    Jaaakee224

Thread Status:
Not open for further replies.

Share This Page