"sponge" block bounce

Discussion in 'Plugin Requests' started by rangewonk, Sep 11, 2016.

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

    rangewonk

    My friend helped me make a sponge block bounce plugin years ago and it has worked fine ever since, however recently it broke and I do not know why.
    My minecraft version is 1.7.10

    When standing on a sponge (if you have the permission) you get launched into the sky. The more sponge blocks under you, the higher you launch.
    This part of the plugin still works, though when you land you shouldn't die. Now for some reason you do. Could someone please use the code below to make an updated version of the plugin for 1.7 + for me please?

    Thanks!

    This is the old plugin code.


    Code:
    package me.rangewonk.BlockBounce;
    
    import java.util.HashSet;
    import java.util.Set;
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.craftbukkit.Main;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.util.Vector;
    
    public class BlockBounce
      extends JavaPlugin
      implements Listener
    {
      public final Logger logger = Logger.getLogger("Minecraft");
      public static Main plugin;
      private PluginManager pm;
      private Set<String> jumped = new HashSet();
      public void onDisable()
      {
        PluginDescriptionFile pdffile = getDescription();
        this.logger.info(pdffile.getFullName() + " Has Been Disabled | By: " +
          pdffile.getAuthors());
      }
      public void onEnable()
      {
        getServer().getPluginManager().registerEvents(this, this);
        PluginDescriptionFile pdffile = getDescription();
        this.logger.info(pdffile.getFullName() + " Has Been Enabled | By: " +
          pdffile.getAuthors());
        this.logger.info("Plugin Version:" + pdffile.getVersion());
        PluginManager pm = getServer().getPluginManager();
      }
      public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
      {
        Player player = (Player)sender;
        Location location = player.getLocation();
        World world = player.getWorld();
        PluginDescriptionFile pdffile = getDescription();
        if (commandLabel.equalsIgnoreCase("blockbounce"))
        {
          if (player.hasPermission("BlockBounce.info"))
          {
            if (args.length < 1)
            {
              sender.sendMessage("§6§L==========§aBlockBounce§6§l==========");
              sender.sendMessage("§c§lCorrect Usage: /blockbounce info");
              sender.sendMessage("§6§l=================================");
              return true;
            }
            if (args[0].equalsIgnoreCase("info"))
            {
              sender.sendMessage("§1§lThis plugin is made by: rangewonk, other info:");
              sender.sendMessage("§eVersion: §3" + pdffile.getVersion());
              sender.sendMessage("§9Visit my youtube: www.youtube.com/rangewonk");
              sender.sendMessage("§aUse permissions: §6BlockBounce.Bouce §aand §6BlockBounce.info)");
              return false;
            }
            return false;
          }
          sender.sendMessage(ChatColor.RED +
            "You do not have permission to preform this action, sorry");
        }
        return false;
      }
      @EventHandler
      public void onPlayerMove(PlayerMoveEvent event)
      {
        Player player = event.getPlayer();
        if (player.hasPermission("BlockBounce.Bounce"))
        {
          Location location = player.getLocation();
          Location standBlock = location.getBlock()
            .getRelative(BlockFace.DOWN).getLocation();
          if (standBlock.getBlock().getTypeId() == 19)
          {
            int xblock = 0;
            double xvel = 0.0D;
            int yblock = -1;
            double yvel = 0.0D;
            int zblock = 0;
            double zvel = 0.0D;
            while (standBlock.getBlock().getLocation().add(xblock, -1.0D, 0.0D).getBlock().getType().equals(Material.SPONGE))
            {
              xblock--;
              xvel += 0.8D;
            }
            while (standBlock.getBlock().getLocation().add(0.0D, yblock, 0.0D).getBlock().getType().equals(Material.SPONGE))
            {
              yblock--;
              yvel += 1.0D;
            }
            while (standBlock.getBlock().getLocation().add(0.0D, -1.0D, zblock).getBlock().getType().equals(Material.SPONGE))
            {
              zblock--;
              zvel += 0.8D;
            }
            xblock = 0;
          
            zblock = 0;
            while (standBlock.getBlock().getLocation().add(xblock, -1.0D, 0.0D).getBlock().getType().equals(Material.SPONGE))
            {
              xblock++;
              xvel -= 0.8D;
            }
            while (standBlock.getBlock().getLocation().add(0.0D, -1.0D, zblock).getBlock().getType().equals(Material.SPONGE))
            {
              zblock++;
              zvel -= 0.8D;
            }
            if (standBlock.getBlock().getLocation().add(0.0D, -1.0D, 0.0D).getBlock().getType().equals(Material.SPONGE))
            {
              player.setVelocity(new Vector(xvel, yvel, zvel));
              String name = player.getName();
              if (!this.jumped.contains(name)) {
                this.jumped.add(name);
              }
            }
          }
        }
      }
      @EventHandler
      public void onEntityDamage(EntityDamageEvent event)
      {
        Entity e = event.getEntity();
        if ((event.getCause() == EntityDamageEvent.DamageCause.FALL) && ((e instanceof Player)))
        {
          String name = ((Player)e).getName();
          if (this.jumped.contains(name))
          {
            this.jumped.remove(name);
            event.setCancelled(true);
          }
        }
      }
    }
     
  2. Offline

    J22929

    maybe use ArrayList instead of a HashSet? I don't really see any issues, seems like it should be working
     
  3. Offline

    rangewonk

    I believe it was my custom kitpvp plugin which was using a higher priority with the damage event. I no longer need help with this. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page