Web blocks not being replaced

Discussion in 'Plugin Development' started by RjSowden, May 5, 2012.

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

    RjSowden

    As quite a few of you might know, my plugin (Punishmental) can be used to, in one instance, create a cube of web blocks around the player, using the code below:
    Code:
    public void ExecuteWeb(CommandSender sender, String[] args){               
            Player subject = getServer().getPlayer(args[1]);           
            subject.chat(ChatColor.YELLOW + "*does ninja moves in front of face to avoid spider webs*");
            Location webb;
            webb = subject.getLocation();
            webb.setX(webb.getX() - 2);
            webb.setY(webb.getY() - 2);
            webb.setZ(webb.getZ() - 2);
            int i = 0;
            while (i < 4){
                i += 1;
                Restoration.put(webb, webb.getBlock().getTypeId());
                log.info(webb.toString());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, subject.getWorld().getBlockAt(webb).getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() - 3);
            webb.setY(webb.getY() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() - 3);
            webb.setY(webb.getY() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() - 3);
            webb.setY(webb.getY() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() + 1);
            Restoration.put(webb, webb.getBlock().getTypeId());
            subject.getWorld().getBlockAt(webb).setTypeId(30);
            webb.setX(webb.getX() - 3);
            webb.setY(webb.getY() - 3);
            webb.setZ(webb.getZ() + 1);
            log.info(webb.toString());
            }
            return;                               
    }
    Long, I know. I'm not prioritizing neatness here, just trying to make the damn thing work.
    The hash map "Restoration" contains a list of blocks and their original states, which it converts them to when this fuinction is called:
    Code:
    public void RestoreDamaged(CommandSender sender, String[] args){
            sender.sendMessage(ChatColor.GRAY + "Clearing Up " + Restoration.size() + " Blocks, Please wait...");
            sender.sendMessage(ChatColor.GRAY + "NB: Web doesn't work for some people. I am working on it.");
            log.info("Locations:");
            Iterator<Entry<Location, Integer>> i = Restoration.entrySet().iterator();
           
    while (i.hasNext() == true){
       
        Entry <Location, Integer> n;
       
        n = i.next();
        log.info("BlockLoc: " + n.getKey().toString());
        log.info("--- BlockID: " + n.getValue());
        n.getKey().getBlock().setTypeId(n.getValue());
    }
            Restoration.clear();
            sender.sendMessage(ChatColor.GREEN + "Clear up finished");
        }
    The RestoreDamaged function works fine for all the other values stored in the "Restoration" hashmap, bar the web command :/.
    When it outputs the entered data, it shows the web blocks locations and their type before hand, but it doesn't change. It stays the same.
    Do web blocks have some special property to change or have I been a collosal idiot?

    Thanks for any help!
     
Thread Status:
Not open for further replies.

Share This Page