Send Block Change

Discussion in 'Plugin Development' started by BurnerDiamond, Mar 6, 2015.

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

    BurnerDiamond

    This seems not to be making a wall:

    Here is the code:

    Code:
    package mc.ecombat;
    
    import org.bukkit.*;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    
    import java.util.HashMap;
    
    /**
    * Created by maxmigliorini on 03/03/15.
    */
    public class Walls {
    
        public static void wallsFill(Player p, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
    
            for (int minX1 = minX; minX1 < maxX; minX1++) {
                for (int minY1 = minY; minY1 < maxY; minY1++) {
                    for (int minZ1 = minZ; minZ1 < maxZ; minZ1++) {
    
                        Location location = new Location(p.getWorld(), minX1, minY1, minZ1);
    
                        p.sendBlockChange(location, Material.STAINED_GLASS, (byte) 14);
    
                    }
                }
            }
        }
    
        public static void wallsEmpty(Player p, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
    
            for (int minX1 = minX; minX1 < maxX; minX1++) {
                for (int minY1 = minY; minY1 < maxY; minY1++) {
                    for (int minZ1 = minZ; minZ1 < maxZ; minZ1++) {
    
                        Location location = new Location(p.getWorld(), minX1, minY1, minZ1);
    
                        p.sendBlockChange(location, Material.AIR, (byte) 0);
    
                    }
                }
            }
        }
    }
    
    And here is the command :

    Code:
    package mc.ecombat;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    /**
    * Created by maxmigliorini on 03/03/15.
    */
    public class Main extends JavaPlugin {
    
        @Override
        public void onEnable() {
    
            getServer().getPluginManager().registerEvents(new Combat(this), this);
    
        }
    
        @Override
        public void onDisable() {
    
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
            if(command.getName().equalsIgnoreCase("glass")) {
    
                Player player = (Player) sender;
    
                Walls.wallsFill(player, 342, 79, 169, 440, 86, 169);
                Walls.wallsFill(player, 440, 79, 71, 440, 86, 169);
                Walls.wallsFill(player, 342, 79, 71, 440, 86, 71);
                Walls.wallsFill(player, 342, 79, 71, 342, 86, 169);
    
                player.sendMessage("GG");
    
            }
            return false;
        }
    }
    
    I debugged it and it does send a message but it doesn't make a wall.

    Thanks!
     
  2. Offline

    mine-care

    Read my signature please....
    Do you want to create a wall for a specific client? or for all?
     
  3. Offline

    BurnerDiamond

    The whole command was for the debug so for now I won't check if the sender is an instanceof Console or something like that.

    It's for a specific client therefore p should work since I am the sender.

    @mine-care

    Fixed!

    Edit: Never Mind was the wrong thing.

    I tried using an old code from a while back and it works perfectly.

    I thought it might be that one of minInt was bigger than the maxInt but it all seems in order.

    I have a feeling that it has something to do with a location.

    This was my old code:

    Code:
    package server.speedpvp.main;
    
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.block.Chest;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    
    import java.util.*;
    import java.util.concurrent.ThreadLocalRandom;
    
    /**
    * Created by maxmigliorini on 28/02/15.
    */
    public class FillChest {
    
        private Main main;
        public FillChest(Main main) {
            this.main = main;
        }
    
        public static void setItemsInChest(Player p) {
    
            World world = p.getWorld();
    
            int minX = -228; int minY = 0; int minZ = -156;
            int maxX = -222; int maxY = 100; int maxZ = -150;
    
            for(int minX1 = minX; minX1 < maxX; minX1++) {
                for(int minY1 = minY; minY1 < maxY; minY1++) {
                    for(int minZ1 = minZ; minZ1 < maxZ; minZ1++) {
                        Block chest = world.getBlockAt(minX1, minY1, minZ1);
                        if(chest.getType() == Material.CHEST) {
                            Chest chestBlock = (Chest) chest.getState();
                            RandomItems(chest, chestBlock);
    
    
    
                        }
                    }
                }
            }
        }
    
    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Mar 6, 2015
  4. Offline

    BurnerDiamond

Thread Status:
Not open for further replies.

Share This Page