[INACTIVE][MISC] BlocksOnGlass v0.44 - Place anything on glass [1185]

Discussion in 'Inactive/Unsupported Plugins' started by FrozenBrain, Apr 16, 2011.

  1. Offline

    FrozenBrain

    BlocksOnGlass - Place everything you want on glass .. and fences .. and ice :>
    Version: v0.44
    CraftBukkit: 1185

    Thanks for the video, @Gabriel Moon

    This plugin allows the players of your server to place anything on glass, ice and fences. Redstone also works.

    Features:
    • Place every item or block on glass, ice, fences and leaves
    • Support for Permissions
    Download BlocksOnGlass v0.44
    Source Code

    If you want to support me, please [​IMG].

    Permissions:
    Show Spoiler
    Players can only place an item on glass if they have the permission to for it.
    There are the following permission nodes:
    bog.itemGlass
    boi.itemIce
    bof.itemFence
    bol.itemLeaves

    If you want to allow them to place a torch on glass, you would use for example
    Code:
    bog.torch
    for wooden doors on fences
    Code:
    bof.wood_door
    and so on.

    The itemname hast to be uncapitalized or it won't work!
    Possible itemnames are:
    Code:
    POWERED_RAIL
    DETECTOR_RAIL
    TORCH (not for fences)
    LADDER
    RAILS
    LEVER
    STONE_PLATE
    WOOD_PLATE
    REDSTONE_TORCH_ON (not for fences)
    STONE_BUTTON
    WOOD_DOOR
    IRON_DOOR
    REDSTONE
    BED
    DIODE
    You can use bog.*, bof.*, boi.* and bol.* as well!


    Configuration:
    fenceFixIf this is set to 'true', you can place fences next to another one even if there's no fence below the new one.


    Changelog:
    Version 0.44
    • Update for CB 1185 (Minecraft 1.8.1)
    Version 0.43
    • Update for CB 1060 and 1118
    Version 0.42
    • Fixed ice (was not melting correctly)
    Version 0.41
    • Added support for leaves
    • Noteblocks placed on glass will now play the correct sound
    Version 0.40
    • Added support for ice
    • Updated for CB build 1000
    • Added "fenceFix" to the config (see above)
    • Monsters can no longer climb over fences
    Show Spoiler
    Version 0.35
    • Snow shouldn't be forming on glass and fences now
    • Torches can now be placed on fences without having to explicitly have the permission to
    Version 0.34
    • Added support for fences
    Version 0.33
    • Fixed lighting bug
    Version 0.32
    • Updated for Minecraft 1.6.6 (CraftBukkit b818)
    Version 0.31
    • Changed the way you can allow or disallow items to be placed on glass
      • See Permissions
    Version 0.30
    • Fixed redstone
    • The plugin has been completely rewritten to make it
      • faster
      • more reliable
      • more flexible
      • more compatible
    Version 0.22
    • Updated for CB 733
    • Added support for powered rails and detector rails
      • You can place them, but they do net work correctly yet, sorry.
    Version 0.21
    • You can now place beds on glass
    Version 0.20
    • Doors can now be placed on glass
    • You can now set which items can be placed on glass (see Configuration)
    • Fixed some bugs
    • Cleaned up the code a bit
    Version 0.11
    • Rails, Ladders, Redstone Wire and Redstone Torches can now be placed on glass (however redstone doesn't work until I know how to fix that)
    • Fixed Ladders
    Version 0.1
    • First public release


    Incompatible plugins: None
    Todo: Fix the sound note blocks make if there's glass below it (may be impossible)

    Have fun :)
     
    _ralts, ACStache, Noppoly and 3 others like this.
  2. Offline

    qrux

    Would it be possible to add fence instead of glass? Like, torches on fences? :)
     
  3. Offline

    FrozenBrain


    That's possible now :)

    It's planned, yes. But then I'll need a new name for the plugin :D
     
  4. Offline

    Unscrewed

    ImpossibleBlocks
     
  5. Offline

    SirHedgehog

    StickyBlocks? I almost made this plugin (called StickyPanes) at one point but the torches were just too annoying to fix.
     
  6. Offline

    RazMaTaz

    PlaceAnywhere! Cept Air.. lol
     
  7. Offline

    PsychoNecrosis

    GlassPlace?
     
  8. howlong does it take you to fix the redstone??
     
  9. Offline

    PsychoNecrosis

    Standard development answer will probably be "it'll be done when it's done"
    You shouldn't push developers for an ETA, it's kinda rude :p
     
  10. i'm srry i was just curious i don't know any thing about java and stuf like that and i prciate the time they put in the plugin developmens so...



    ps. srry for bad english i'm dutch
     
  11. Offline

    Nananea

    Think you just need to have all your users use Better Glass client side. :(
     
  12. Offline

    FrozenBrain

    Absolutely. I have no idea on how to fix redstone as it seems to be (almost) impossible to do.

    Funny fact: If you change only one line of the server's source glass would act like any other block. You could place redstone on it or put torches on it and so on. But I don't think that I can do this with a plugin.
     
  13. Offline

    fifth

    Sounds like something for the bukkit devs to implement then? IDK I DONT REALLY KNOW ABOUT HOW THESE THINGS WORK

    ANYWAY the reason I came in here was to say this plugin sounds totally ace and is gonna be a real swell addition to my server, thanks for writing it!
     
  14. Offline

    cedirockLP

    Works. Nice.
     
  15. Offline

    FrozenBrain

    Updated for MC 1.5 (CB Build 733)
     
  16. Offline

    iCreate

    Is there a repository somewhere with older versions of this plugin? I have the most up-to date version, but I'm running on 1.4_01 and it keeps spewing out errors about the Detector Rails. I would like to use this plugin without the constant posting of these errors. Thanks for a great plugin ^-^

    Code:
    Could not pass event BLOCK_PHYSICS to BlocksOnGlass
    java.lang.NoSuchFieldError: DETECTOR_RAIL
        at de.frozenbrain.BlocksOnGlass.bogBlockListener.onBlockPhysics(bogBlockListener.java:25)
        at org.bukkit.plugin.java.JavaPluginLoader$23.execute(JavaPluginLoader.java:338)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:59)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:257)
        at net.minecraft.server.World.k(World.java:367)
        at net.minecraft.server.World.h(World.java:355)
        at net.minecraft.server.World.f(World.java:323)
        at net.minecraft.server.World.e(World.java:295)
        at net.minecraft.server.BlockGrass.a(SourceFile:38)
        at net.minecraft.server.World.i(World.java:1475)
        at net.minecraft.server.World.h(World.java:1406)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:359)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:283)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    
     
  17. Offline

    sukosevato

    I have a new idea that would be great. Maybe it can be integrated in this plugin or maybe it has to be a separate plugin, don't know.

    The thing is, when you use stone slabs (which look pretty cool as a floor) then you can't place torches on it. And all other stuff you place on it will float like half a block above it. That last part isn't really easily to fix i think. Since then minecraft has to add more dimensions or something. But the torches on a stone slab should be doable? (At least i guess :O)

    Is that possible? Added support for placing a torch on a slab. So like halfway a block.

    Thank you for taking your time for this again.
     
  18. Offline

    arsjet

  19. Offline

    Jackjan

    Maybe you cann add Pressure Plates on Glass. That would be really nice :)
     
  20. Offline

    emoknight

    can u fix the redstone on glass.. i cant sent power 2 it then it on glass
     
  21. Offline

    drndos

    To add stone button support do this:
    [Open] bogPlugin.java
    [Find]
    Code:
    public boolean canPlaceBeds;
    [After Add]
    Code:
    public boolean canPlaceStoneButton;
    [Find]
    Code:
    canPlaceBeds = config.getBoolean("allowBed", true);
    [After Add]
    Code:
    canPlaceStoneButton = config.getBoolean("allowStoneButton", true);
    [Open] bogPlayerListener.java
    [Find]
    Code:
    } else if((event.getPlayer().getItemInHand().getType() == Material.BED) && (event.getBlockFace() == BlockFace.UP) && plugin.canPlaceBeds) {
    [Before Add]
    Code:
    }else if((event.getPlayer().getItemInHand().getType() == Material.STONE_BUTTON) && !(event.getBlockFace() == BlockFace.DOWN) && !(event.getBlockFace() == BlockFace.UP) && plugin.canPlaceStoneButton) {
    					block.setType(Material.DIRT);
    					block.getFace(event.getBlockFace()).setType(Material.STONE_BUTTON);
    					fixTorch(block.getFace(event.getBlockFace()), event.getBlockFace());
    					event.getClickedBlock().setType(Material.GLASS);
    					takeItem(event);
    [Open] bogBlockListener.java
    [Find]
    Code:
    (event.getBlock().getType() == Material.REDSTONE_TORCH_OFF) ||
    [After Add]
    Code:
    (event.getBlock().getType() == Material.STONE_BUTTON) ||
    [Find]
    Code:
    } else if(block.getType() == Material.LADDER) {
    [Before Add]
    Code:
    } else if(block.getType() == Material.STONE_BUTTON) {
                switch (data) {
                    case 0x1:
                        return block.getFace(BlockFace.NORTH).getType();
                    case 0x2:
                        return block.getFace(BlockFace.SOUTH).getType();
                    case 0x3:
                        return block.getFace(BlockFace.EAST).getType();
                    case 0x4:
                        return block.getFace(BlockFace.WEST).getType();
                    case 0x9:
                      return block.getFace(BlockFace.NORTH).getType();
                    case 0xA:
                      return block.getFace(BlockFace.SOUTH).getType();
                    case 0xC:
                      return block.getFace(BlockFace.WEST).getType();
                    case 0xB:
                      return block.getFace(BlockFace.EAST).getType();
                }
                return null;
    Also add this line to config.yml
    Code:
    allowStoneButton: true
    I also found a way to fix the redstone! to fix it do this:
    [Open] bogBlockListener.java
    [Find]
    Code:
    } else if((block.getType() == Material.REDSTONE_WIRE) || (block.getType() == Material.BED_BLOCK)) {
                return block.getFace(BlockFace.DOWN).getType();
                
    [Replace with]
    Code:
            } else if ((block.getType() == Material.BED_BLOCK)) {
          return block.getFace(BlockFace.DOWN).getType();
        } else if ((block.getType() == Material.REDSTONE_WIRE)) {
          if (block.getFace(BlockFace.DOWN).getType() == Material.GLASS) {
            if(block.isBlockPowered())
            {
              block.setData((byte)0xD);
            }
            else
            {
            block.setData((byte)0x0);
            }
          }
          return block.getFace(BlockFace.DOWN).getType();
    To add pressure plate support do this:
    [Open] bogPlugin.java
    [Find]
    Code:
    public boolean canPlaceBeds;

    [After Add]
    Code:
    public boolean canPlacePressurePlate;

    [Find]
    Code:
    canPlaceBeds = config.getBoolean("allowBed", true);

    [After Add]
    Code:
    canPlacePressurePlate = config.getBoolean("allowPressurePlate", true);


    [Open] bogPlayerListener.java
    [Find]
    Code:
    } else if((event.getPlayer().getItemInHand().getType() == Material.BED) && (event.getBlockFace() == BlockFace.UP) && plugin.canPlaceBeds) {

    [Before Add]
    Code:
    } else if ((event.getPlayer().getItemInHand().getType() == Material.STONE_PLATE) && (event.getBlockFace() == BlockFace.UP) && plugin.canPlacePressurePlate) {
    					block.setType(Material.DIRT);
    					block.getFace(event.getBlockFace()).setType(Material.STONE_PLATE);
    					fixTorch(block.getFace(event.getBlockFace()), event.getBlockFace());
    					event.getClickedBlock().setType(Material.GLASS);
    					takeItem(event);

    [Open] bogBlockListener.java
    [Find]
    Code:
    (event.getBlock().getType() == Material.REDSTONE_TORCH_OFF) ||

    [After Add]
    Code:
    (event.getBlock().getType() == Material.STONE_PLATE) ||

    [Find]
    Code:
    } else if(block.getType() == Material.LADDER) {

    [Before Add]
    Code:
    } else if (block.getType() == Material.STONE_PLATE) {
              return block.getFace(BlockFace.DOWN).getType();

    Also add this line to config.yml
    Code:
    allowPressurePlate: true


    Sorry for SPAM, I worked on these for hours :) Finally I understand the Bukkit API :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  22. Offline

    FrozenBrain

    @drndos: You could've just asked for pressure plate and button support :)

    The code for the redstone wire does not work. It causes an StackOverflowError.

    You can download an older commit from github and compile it yourself if you want.

    Good idea, I'll add this later.

    I'm aware of that. But it seems to a be a bug I can't fix.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  23. Offline

    drndos

    The code for redstone works for me. dunno why but works, I can send you my source codes maybe I forgot something.
     
  24. Offline

    xGhOsTkiLLeRx

    Any progess of a version with redstone @FrozenBrain ?
    Would be cool!
     
  25. Offline

    BlueJayofEvil

    Iron doors do not seem to work when placed on glass. I put a switch right next to it and still nothing. It worked when I changed the floor beneath it to a different material. Is this related to the redstone issue?

    CraftBukkit build 755
     
  26. Offline

    drndos

    I have some progress, it works in most of the cases. But when you create loop It overloads the server and in some cases the redstone wire doesn't work but when you won't create loops and always create two blocks of glass with redstone on it it works :)

    Yes it is

    For FrozenBrain:
    Code:
    package de.frozenbrain.BlocksOnGlass;
    
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockListener;
    import org.bukkit.event.block.BlockPhysicsEvent;
    import org.bukkit.inventory.ItemStack;
    
    public class bogBlockListener extends BlockListener {
    
      private final bogPlugin plugin;
    
      public bogBlockListener(bogPlugin plugin) {
        this.plugin = plugin;
      }
    
      @Override
      public void onBlockPhysics(BlockPhysicsEvent event) {
        checkRedstone(event.getBlock());
        if ((event.getBlock().getType() == Material.TORCH)
                || (event.getBlock().getType() == Material.REDSTONE_TORCH_ON)
                || (event.getBlock().getType() == Material.REDSTONE_TORCH_OFF)
                || (event.getBlock().getType() == Material.STONE_BUTTON)
                || (event.getBlock().getType() == Material.STONE_PLATE)
                || (event.getBlock().getType() == Material.RAILS)
                || (event.getBlock().getType() == Material.DETECTOR_RAIL)
                || (event.getBlock().getType() == Material.POWERED_RAIL)
                || (event.getBlock().getType() == Material.REDSTONE_WIRE)
                || (event.getBlock().getType() == Material.LADDER)
                || (event.getBlock().getType() == Material.WOODEN_DOOR)
                || (event.getBlock().getType() == Material.IRON_DOOR_BLOCK)) {
          if (getAttachedBlock(event.getBlock()) == Material.GLASS) {
            event.setCancelled(true);
          }
        }
      }
    
      protected void checkBlock(Block block, BlockFace f) {
        if ((block.getFace(f).getType() == Material.REDSTONE_WIRE) && (block.getFace(f).getFace(BlockFace.DOWN).getType() == Material.GLASS)) {
          System.out.print("found");
          if (block.getFace(f).getData() == ((byte) 0x0)) {
            System.out.print("and changing");
            int var = block.getData();
            block = block.getFace(f);
    
            block.setData((byte) 0xD, true);
            check(block, f);
          } else {
            System.out.print("Is already powered");
          }
    
        }
      }
    
      protected void check(Block block) {
        System.out.print("Checking East");
        checkBlock(block, BlockFace.EAST);
        System.out.print("Checking WEST");
        checkBlock(block, BlockFace.WEST);
        System.out.print("Checking NORTH");
        checkBlock(block, BlockFace.NORTH);
        System.out.print("Checking South");
        checkBlock(block, BlockFace.SOUTH);
      }
    
      protected void check(Block block, BlockFace f) {
        if (f == BlockFace.EAST) {
          System.out.print("Checking East");
          checkBlock(block, BlockFace.SOUTH);
          System.out.print("Checking NORTH");
          checkBlock(block, BlockFace.NORTH);
          System.out.print("Checking South");
          checkBlock(block, BlockFace.WEST);
        }
        if (f == BlockFace.WEST) {
          System.out.print("Checking WEST");
          checkBlock(block, BlockFace.SOUTH);
          System.out.print("Checking NORTH");
          checkBlock(block, BlockFace.NORTH);
          System.out.print("Checking South");
          checkBlock(block, BlockFace.EAST);
        }
        if (f == BlockFace.NORTH) {
          System.out.print("Checking WEST");
          checkBlock(block, BlockFace.WEST);
          System.out.print("Checking East");
          checkBlock(block, BlockFace.EAST);
          System.out.print("Checking NORTH");
          checkBlock(block, BlockFace.SOUTH);
        }
        if (f == BlockFace.SOUTH) {
          System.out.print("Checking WEST");
          checkBlock(block, BlockFace.WEST);
          System.out.print("Checking East");
          checkBlock(block, BlockFace.EAST);
          System.out.print("Checking South");
          checkBlock(block, BlockFace.NORTH);
        }
      }
    
      public void checkDirections(Block block) {
      }
    
      public void checkRedstone(Block block) {
        if (block.getType() == Material.REDSTONE_WIRE) {
          if (block.getFace(BlockFace.DOWN).getType() == Material.GLASS) {
            if (block.getFace(BlockFace.NORTH).getType() == Material.REDSTONE_WIRE) {
              if (block.getFace(BlockFace.NORTH).getData() > (byte) 0x0) {
                check(block, BlockFace.NORTH);
              }
            }
            if (block.getFace(BlockFace.SOUTH).getType() == Material.REDSTONE_WIRE) {
              if (block.getFace(BlockFace.SOUTH).getData() > (byte) 0x0) {
                check(block, BlockFace.SOUTH);
              }
            }
            if (block.getFace(BlockFace.EAST).getType() == Material.REDSTONE_WIRE) {
              if (block.getFace(BlockFace.EAST).getData() > (byte) 0x0) {
                check(block, BlockFace.EAST);
              }
            }
            if (block.getFace(BlockFace.WEST).getType() == Material.REDSTONE_WIRE) {
              if (block.getFace(BlockFace.WEST).getData() > (byte) 0x0) {
                check(block, BlockFace.WEST);
              }
            }
      
          }
        }
      }
    
      @Override
      public void onBlockBreak(BlockBreakEvent event) {
        Block block = event.getBlock();
        if (block.getType() == Material.GLASS) {
          Block north = block.getFace(BlockFace.NORTH);
          Block east = block.getFace(BlockFace.EAST);
          Block south = block.getFace(BlockFace.SOUTH);
          Block west = block.getFace(BlockFace.WEST);
          Block up = block.getFace(BlockFace.UP);
    
          ItemStack dropTorch = new ItemStack(Material.TORCH, 1);
    
          if (north.getType() == Material.TORCH) {
            if (north.getData() == 0x2) {
              north.setType(Material.AIR);
              north.getWorld().dropItemNaturally(north.getLocation(), dropTorch);
            }
          }
          if (east.getType() == Material.TORCH) {
            if (east.getData() == 0x4) {
              east.setType(Material.AIR);
              east.getWorld().dropItemNaturally(east.getLocation(), dropTorch);
            }
          }
          if (south.getType() == Material.TORCH) {
            if (south.getData() == 0x1) {
              south.setType(Material.AIR);
              south.getWorld().dropItemNaturally(south.getLocation(), dropTorch);
            }
          }
          if (west.getType() == Material.TORCH) {
            if (west.getData() == 0x3) {
              west.setType(Material.AIR);
              west.getWorld().dropItemNaturally(west.getLocation(), dropTorch);
            }
          }
          if (up.getType() == Material.TORCH) {
            if (up.getData() == 0x5) {
              up.setType(Material.AIR);
              up.getWorld().dropItemNaturally(up.getLocation(), dropTorch);
            }
          }
        }
      }
    
      private Material getAttachedBlock(Block block) {
        byte data = block.getData();
        if ((block.getType() == Material.RAILS)
                || (block.getType() == Material.DETECTOR_RAIL)
                || (block.getType() == Material.POWERED_RAIL)) {
          switch (data) {
            case 0x3:
              return block.getFace(BlockFace.NORTH).getType();
            case 0x2:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x4:
              return block.getFace(BlockFace.EAST).getType();
            case 0x5:
              return block.getFace(BlockFace.WEST).getType();
            default:
              return block.getFace(BlockFace.DOWN).getType();
          }
    
        } else if ((block.getType() == Material.BED_BLOCK)) {
          return block.getFace(BlockFace.DOWN).getType();
        } else if ((block.getType() == Material.REDSTONE_WIRE)) {
          return block.getFace(BlockFace.DOWN).getType();
        } else if ((block.getType() == Material.WOODEN_DOOR)
                || (block.getType() == Material.IRON_DOOR_BLOCK)) {
          if (plugin.hasBit(block.getData(), (byte) 0x8)) {
            return block.getFace(BlockFace.DOWN, 2).getType();
          } else {
            return block.getFace(BlockFace.DOWN).getType();
          }
    
        } else if (block.getType() == Material.LADDER) {
          switch (data) {
            case 0x2:
              return block.getFace(BlockFace.WEST).getType();
            case 0x3:
              return block.getFace(BlockFace.EAST).getType();
            case 0x4:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x5:
              return block.getFace(BlockFace.NORTH).getType();
          }
          return null;
    
        } else if (block.getType() == Material.STONE_BUTTON) {
          switch (data) {
            case 0x1:
              return block.getFace(BlockFace.NORTH).getType();
            case 0x2:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x3:
              return block.getFace(BlockFace.EAST).getType();
            case 0x4:
              return block.getFace(BlockFace.WEST).getType();
            case 0x9:
              return block.getFace(BlockFace.NORTH).getType();
            case 0xA:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0xC:
              return block.getFace(BlockFace.WEST).getType();
            case 0xB:
              return block.getFace(BlockFace.EAST).getType();
          }
          return null;
        } else if (block.getType() == Material.STONE_PLATE) {
          return block.getFace(BlockFace.DOWN).getType();
        } else {
          switch (data) {
            case 0x1:
              return block.getFace(BlockFace.NORTH).getType();
            case 0x2:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x3:
              return block.getFace(BlockFace.EAST).getType();
            case 0x4:
              return block.getFace(BlockFace.WEST).getType();
            case 0x5:
              return block.getFace(BlockFace.DOWN).getType();
            default:
              return Material.AIR;
          }
        }
      }
    }
    
    This is some progress today, I will have to fix some issues and stuff but the idea is good I think.
    You have to put ie. dirt block then minimal 2x Glass blocks and again dirt block all with redstone on it. Then If you lit the first end the other will be lit too. The power is all the way 12 I know how to fix this but there are more issues then. I hope I will fix all the issues tomorrow :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  27. Offline

    FrozenBrain

    Yes, the switch works with redstone and redstone doesn't work.
     
  28. Offline

    drndos

    FrozenBrain take a look at this:
    Code:
    package de.frozenbrain.BlocksOnGlass;
    
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockListener;
    import org.bukkit.event.block.BlockPhysicsEvent;
    import org.bukkit.inventory.ItemStack;
    
    public class bogBlockListener extends BlockListener {
    
      private final bogPlugin plugin;
    
      public bogBlockListener(bogPlugin plugin) {
        this.plugin = plugin;
      }
    
      @Override
      public void onBlockPhysics(BlockPhysicsEvent event) {
        checkRedstone(event.getBlock());
        if ((event.getBlock().getType() == Material.TORCH)
                || (event.getBlock().getType() == Material.REDSTONE_TORCH_ON)
                || (event.getBlock().getType() == Material.REDSTONE_TORCH_OFF)
                || (event.getBlock().getType() == Material.STONE_BUTTON)
                || (event.getBlock().getType() == Material.STONE_PLATE)
                || (event.getBlock().getType() == Material.RAILS)
                || (event.getBlock().getType() == Material.DETECTOR_RAIL)
                || (event.getBlock().getType() == Material.POWERED_RAIL)
                || (event.getBlock().getType() == Material.REDSTONE_WIRE)
                || (event.getBlock().getType() == Material.LADDER)
                || (event.getBlock().getType() == Material.WOODEN_DOOR)
                || (event.getBlock().getType() == Material.IRON_DOOR_BLOCK)) {
          if (getAttachedBlock(event.getBlock()) == Material.GLASS) {
            event.setCancelled(true);
          }
        }
      }
    
      protected void checkBlock(Block block, BlockFace f) {
        if ((block.getFace(f).getType() == Material.REDSTONE_WIRE) && (block.getFace(f).getFace(BlockFace.DOWN).getType() == Material.GLASS)) {
          if (block.getFace(f).getData() == ((byte) 0x0)) {
            int var = block.getData();
            block = block.getFace(f);
            block.setData((byte) (var - 1), false);
            check(block, f, true);
          }
        } else if ((block.getFace(f).getType() == Material.REDSTONE_WIRE)) {
          if (block.getFace(f).getData() == ((byte) 0x0)) {
            int var = block.getData();
            block = block.getFace(f);
            block.setData((byte) (var - 1), true);
          }
        }
      }
    
      protected void check(Block block, BlockFace f) {
        if (f == BlockFace.EAST) {
          checkBlock(block, BlockFace.SOUTH);
          checkBlock(block, BlockFace.NORTH);
          checkBlock(block, BlockFace.WEST);
        }
        if (f == BlockFace.WEST) {
          checkBlock(block, BlockFace.SOUTH);
          checkBlock(block, BlockFace.NORTH);
          checkBlock(block, BlockFace.EAST);
        }
        if (f == BlockFace.NORTH) {
          checkBlock(block, BlockFace.WEST);
          checkBlock(block, BlockFace.EAST);
          checkBlock(block, BlockFace.SOUTH);
        }
        if (f == BlockFace.SOUTH) {
          checkBlock(block, BlockFace.WEST);
          checkBlock(block, BlockFace.EAST);
          checkBlock(block, BlockFace.NORTH);
        }
      }
    
      protected void check(Block block, BlockFace f, boolean dummy) {
        if (f == BlockFace.EAST) {
          checkBlock(block, BlockFace.SOUTH);
          checkBlock(block, BlockFace.NORTH);
          checkBlock(block, BlockFace.EAST);
        }
        if (f == BlockFace.WEST) {
          checkBlock(block, BlockFace.SOUTH);
          checkBlock(block, BlockFace.NORTH);
          checkBlock(block, BlockFace.WEST);
        }
        if (f == BlockFace.NORTH) {
          checkBlock(block, BlockFace.WEST);
          checkBlock(block, BlockFace.EAST);
          checkBlock(block, BlockFace.NORTH);
        }
        if (f == BlockFace.SOUTH) {
    
          checkBlock(block, BlockFace.WEST);
          checkBlock(block, BlockFace.EAST);
          checkBlock(block, BlockFace.SOUTH);
        }
      }
    
      public void checkRedstone(Block block) {
        if (block.getType() == Material.REDSTONE_WIRE) {
          if (block.getFace(BlockFace.DOWN).getType() == Material.GLASS) {
            BlockFace[] blockfaces = {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
            for (int i = 0; i < 4; i++) {
              if (block.getFace(blockfaces[i]).getType() == Material.REDSTONE_WIRE) {
                if (block.getFace(blockfaces[i]).getData() > (byte) 0x0) {
                  if (block.getData() == (byte) 0x0) {
                    int var = block.getFace(blockfaces[i]).getData();
                    block.setData((byte) (var - 1), false);
                    check(block, blockfaces[i]);
                  }
                }
              }
            }
          }
        }
      }
    
      @Override
      public void onBlockBreak(BlockBreakEvent event) {
        Block block = event.getBlock();
        if (block.getType() == Material.GLASS) {
          Block north = block.getFace(BlockFace.NORTH);
          Block east = block.getFace(BlockFace.EAST);
          Block south = block.getFace(BlockFace.SOUTH);
          Block west = block.getFace(BlockFace.WEST);
          Block up = block.getFace(BlockFace.UP);
    
          ItemStack dropTorch = new ItemStack(Material.TORCH, 1);
    
          if (north.getType() == Material.TORCH) {
            if (north.getData() == 0x2) {
              north.setType(Material.AIR);
              north.getWorld().dropItemNaturally(north.getLocation(), dropTorch);
            }
          }
          if (east.getType() == Material.TORCH) {
            if (east.getData() == 0x4) {
              east.setType(Material.AIR);
              east.getWorld().dropItemNaturally(east.getLocation(), dropTorch);
            }
          }
          if (south.getType() == Material.TORCH) {
            if (south.getData() == 0x1) {
              south.setType(Material.AIR);
              south.getWorld().dropItemNaturally(south.getLocation(), dropTorch);
            }
          }
          if (west.getType() == Material.TORCH) {
            if (west.getData() == 0x3) {
              west.setType(Material.AIR);
              west.getWorld().dropItemNaturally(west.getLocation(), dropTorch);
            }
          }
          if (up.getType() == Material.TORCH) {
            if (up.getData() == 0x5) {
              up.setType(Material.AIR);
              up.getWorld().dropItemNaturally(up.getLocation(), dropTorch);
            }
          }
        }
      }
    
      private Material getAttachedBlock(Block block) {
        byte data = block.getData();
        if ((block.getType() == Material.RAILS)
                || (block.getType() == Material.DETECTOR_RAIL)
                || (block.getType() == Material.POWERED_RAIL)) {
          switch (data) {
            case 0x3:
              return block.getFace(BlockFace.NORTH).getType();
            case 0x2:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x4:
              return block.getFace(BlockFace.EAST).getType();
            case 0x5:
              return block.getFace(BlockFace.WEST).getType();
            default:
              return block.getFace(BlockFace.DOWN).getType();
          }
    
        } else if ((block.getType() == Material.BED_BLOCK)) {
          return block.getFace(BlockFace.DOWN).getType();
        } else if ((block.getType() == Material.REDSTONE_WIRE)) {
          return block.getFace(BlockFace.DOWN).getType();
        } else if ((block.getType() == Material.WOODEN_DOOR)
                || (block.getType() == Material.IRON_DOOR_BLOCK)) {
          if (plugin.hasBit(block.getData(), (byte) 0x8)) {
            return block.getFace(BlockFace.DOWN, 2).getType();
          } else {
            return block.getFace(BlockFace.DOWN).getType();
          }
    
        } else if (block.getType() == Material.LADDER) {
          switch (data) {
            case 0x2:
              return block.getFace(BlockFace.WEST).getType();
            case 0x3:
              return block.getFace(BlockFace.EAST).getType();
            case 0x4:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x5:
              return block.getFace(BlockFace.NORTH).getType();
          }
          return null;
    
        } else if (block.getType() == Material.STONE_BUTTON) {
          switch (data) {
            case 0x1:
              return block.getFace(BlockFace.NORTH).getType();
            case 0x2:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x3:
              return block.getFace(BlockFace.EAST).getType();
            case 0x4:
              return block.getFace(BlockFace.WEST).getType();
            case 0x9:
              return block.getFace(BlockFace.NORTH).getType();
            case 0xA:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0xC:
              return block.getFace(BlockFace.WEST).getType();
            case 0xB:
              return block.getFace(BlockFace.EAST).getType();
          }
          return null;
        } else if (block.getType() == Material.STONE_PLATE) {
          return block.getFace(BlockFace.DOWN).getType();
        } else {
          switch (data) {
            case 0x1:
              return block.getFace(BlockFace.NORTH).getType();
            case 0x2:
              return block.getFace(BlockFace.SOUTH).getType();
            case 0x3:
              return block.getFace(BlockFace.EAST).getType();
            case 0x4:
              return block.getFace(BlockFace.WEST).getType();
            case 0x5:
              return block.getFace(BlockFace.DOWN).getType();
            default:
              return Material.AIR;
          }
        }
      }
    }
    
    It is working. No errors so far. I tried Loops and other things everything works.
    The bugs still are: Glass block must be powered from normal block at the same level by redstone wire. (It is not such a bug, but if you want to power the block by torch or from block beneath it is annoying) The output wire from glass must be connected to two normal blocks on the same level to make it work. When you destroy powered redstone wire on glass the connected redstone wire on glass will not be unpowered.=> you have to first unpower the source and then destroy redstone wires.
     
  29. Offline

    FrozenBrain








    I finally found a way to make the plugin much more reliable and faster. I also removed about 360 lines of code.

    And the best: Redstone is working perfectly.

    I just have to fix some bugs, the update will be out soon :)

    [​IMG]
     
  30. Offline

    BlueJayofEvil

    Good to hear! Your plugin has been very helpful on my server. :)
     
  31. Offline

    FrozenBrain

    Done. I also added support for permissions so you can individualy allow or disallow each player placing items on glass.

    @All: Read the first post before updating or you'll fail using it.
     

Share This Page