[1.0.2] Brick Restriction System

Author Topic: [1.0.2] Brick Restriction System  (Read 3937 times)

An add-on that allows you to - you guessed it - restrict bricks. So let's say I only want admins to be able to place the Christmas tree brick. Then I place a Christmas tree brick, look at it, and type in "/setAdminBrickLevel 1" to add it to the restriction list. And bam, now only Admins and Super Admins can use the Christmas tree brick.

Code: [Select]
Console Commands:
AdminBrickData.listBricks(); - Lists currently restricted bricks, along with their required rank.
AdminBrickData.removeAdminBrick(<Brick datablock name>); - Remove a brick datablock from the list. Here's an example of a brick datablock name: "brick1x1Data" is the 1x1 block. Not all add-ons use this format in their datablock names, however, so I recommend using /setBrickAdminLevel in-game.
AdminBrickData.addAdminBrick(<Brick datablock name>,<Required rank: 1 for admin, 2 for superadmin>); - Add a brick datablock to the list with a requirement level.
Code: [Select]
Server Commands:
/listAdminBrickLevels - Lists currently restricted bricks, along with their required rank.
/setAdminBrickLevel <Required rank: 0 for none, 1 for admin, 2 for superadmin> - (Super Admin only) Adds / removes a required rank a brick datablock. You must be looking at a brick with the datablock you want to restrict / unrestrict for this one to work.
/clearRestrictedBricks - (Admin Only) Clears all restricted bricks. This means that if the owner of the brick doesn't meet the brick's requirements, the brick is deleted.
Download on Blockland Glass
« Last Edit: December 13, 2016, 11:02:08 AM by RTBARCHIVE »


Does anyone think it would be nice to add a GUI to this add-on? Similar to that of  the brick selector GUI, but you can change if the brick is restricted or not.

Why not just add buttons to the brick selector gui?

Why not just add buttons to the brick selector gui?
Would require a client-side add-on, but it's possible.

Would require a client-side add-on, but it's possible.
given that server hosts are the one using this, i don't think its too bad to require it

Would require a client-side add-on, but it's possible.
given that server hosts are the one using this, i don't think its too bad to require it
Not only that, but he was also asking if he should add a gui to it.


Why not just add buttons to the brick selector gui?
I thought about this, but I thought it would crowd the buttons too much (unless I make 8x8 button icons (im not a good artist)).

The client doesn't necessarily need the add-on; The /setadminbricklevel would compensate for clients who do not have the client-side addon but who still wish to restrict bricks.

- Scratch all this, I just created some simplistic, minimalistic bitmaps; I've already begun work on adding buttons to the brick selector GUI.-
« Last Edit: December 12, 2016, 10:32:00 PM by RTBARCHIVE »

I have needed this since forever, thank you.

GUI Implementation (Yes, in just one day after I released the initial content!)

Here are a set of explanations of the things that I have circled in the image above:

Blue circle (Progress bar) - This bar mesaures how far you are into downloading all bricks' requirement statuses. Whenever you join a server (and this will happen everytime), you will have to require every brick's requirement status. Now, this may take from a few seconds to three minutes. To counter this, I have made it so that it downloads in the background while you are in-game. You can check the progress at any time by going into the brick selection GUI. I have also made it where the progress bar is shown on the play gui, should it be visible.
Little note here; You can click on the progress bar to change it displaying percentage format or 'current value/max value' format.

Purple circle - These are category options. Instead of tediously clicking on every small button to set every brick in a category to admin-only, you can simply use these buttons.

Red circle (Located on the Pine Tree brick button) - These are buttons that will be found on every brick button. With them, you can manage the restriction of a brick. I've made them very small so that you aren't trying to avoid them every time you go to select a brick. Now, you will (hopefully) never see a brick button with the specific bitmaps shown on the Pine Tree brick button; I just edited them that way so I can explain what each of them mean.

  +  First, the button on the left:
        If a button has this bitmap, it means that this is the currently selected restriction for this brick.

  + Second, the middle button:
        This is an unselected restriction setting for a brick. (Note that it is not specific to having an 'A' label; more on this later in the post)

  + Lastly, the button on the right
        If a button has this bitmap, it either means there was an error (ex. you tried to set a brick restriction while you weren't an admin), or the brick restriction properties haven't loaded yet.

Going back to the unselected restriction bitmap, there are three labels that you will see (in this order):
'E', 'A', and 'S'
These labels are meant to represent the three restriction levels:
'Everyone', 'Admin', and 'Super Admin'. By the way, the 'Everyone' restriction level doesn't mean that no-one can use the brick; it means everyone can use the brick.

And there you have it. If you find any bugs, I would really appreciate it if you told me.

Anyways, it's 11PM, and I should go get some sleep.
« Last Edit: December 13, 2016, 12:15:39 AM by RTBARCHIVE »

Why does it take up to 3 minutes to get a few booleans?  I'm sure you can do a lot better than that...

You could fit 1785 'requirement statuses' (if not more) into each argument of each clientCmd if you just send it as 7 bits per character. Most servers don't even have that many bricks.

Alright, I'm up, it's morning, and it's time to clean up what I forgot / didn't think of while I was drowsy.

You could fit 1785 'requirement statuses' (if not more) into each argument of each clientCmd if you just send it as 7 bits per character. Most servers don't even have that many bricks.
Why does it take up to 3 minutes to get a few booleans?  I'm sure you can do a lot better than that...
Right, I'll fix this up. Also, 'requirement statuses' is a really bad thing to call the data on this add-on, but I really couldn't think of anything else to call it

Version 1.0.1
Code: [Select]
+ Admin Brick Data transfer now takes 3-5 seconds as opposed to 3 minutes (credit to Portify for helping me out)
+ Fixed bug where restriction management buttons were still red even after the data was done transferring
+ Fixed some slow-down when you modified entire categories
+ Added /clearRestrictedBricks

Version 1.0.2
Code: [Select]
+ Removed left-over debug garbage
« Last Edit: December 13, 2016, 11:02:02 AM by RTBARCHIVE »