create account

Minecolonies & Some GUI abstractions by raycoms

View this thread on steemit.com
· @raycoms ·
$78.92
Minecolonies & Some GUI abstractions
![](https://i.imgur.com/aymhEt2.png)

Hi everyone, as you guys now, abstracting and refactoring things is one of my big programming hobbies and while setting up some new features I noticed that I could save a whole lot of code if I would break this task down into abstracting the existing code and then in the next step using this for the new GUI.
In this first post, I will head into the abstraction work and the new features will be explained in the following post.

What is it about:
---

Now, for quite a while already we had GUIs displaying lists of items where the player was able to select certain items for certain actions and in one of these GUIs, we even had an input option to filter.

But, there were all scattered all over the place and had nothing in common. And while only one had the input filter, all of them could actually make use of this.

For this reason, I created one universal filterable GUI which will have the items, an on/off the trigger and input on top for filtering.

![](https://i.imgur.com/1r6FQSO.png)


The first step of this was defining a building type which would define what kind of data would be needed on the server side.

![](https://i.imgur.com/I5OyZPk.png)


Read and write the data from disk.

![](https://i.imgur.com/H3Z1xk1.png)

Besides that, it needs the methods to manipulate the ArrayList and finally a way to serialize it to send it to the client side.

![](https://i.imgur.com/cshi0tB.png)

Then I needed a client-side representation for it as well:

![](https://i.imgur.com/G5RZyuq.png)

Where the add and remove methods would already do the synching to the server side.

![](https://i.imgur.com/s9yvKja.png)
![](https://i.imgur.com/zOV6Xvf.png)

And a method to deserialize it.

![](https://i.imgur.com/cKnm8zf.png)

Also, I edited the existing message to make it more generic for this purpose.

![](https://i.imgur.com/PMVWguo.png)

And register it to the network.

![](https://i.imgur.com/sEMIrUK.png)

Then, I created the abstract window class.

![](https://i.imgur.com/avrvum8.png)

Which would take care of switching the pages, register the on/off button and set up the lists and the description label of the list?

![](https://i.imgur.com/kXkm3Zh.png)

When clicking on the switch button it would trigger it and change it to on/off depending on the previous state and also trigger the building view which as previously explained would then trigger the server update.

![](https://i.imgur.com/YF4fF5T.png)

On open, most importantly it queries all items which fit the required description and filter.

![](https://i.imgur.com/UPrcx7d.png)

After getting it from the blockList and from the exception list.

> Those would be overridden by the final GUI.

![](https://i.imgur.com/XlA48tv.png)

On key typed, it would update the resources to update the filter.

![](https://i.imgur.com/W9YLTFo.png)

Similar, in the update element of the list it would check if the item is contained in the list or not it would set the icons etc of the list.

![](https://i.imgur.com/dm7xk3S.png)

And finally, to create a working worker I just had to make sure to extend the right classes and override the list of blocks.

Resulting in this very simple composter window.
This will make it way easier for new devs to enter and create simple GUIs for a worker which requires this functionality.

![](https://i.imgur.com/rncet72.png)


Extra bits:
---

Since people asked, we also added a config option to turn on/off the holiday special.

With the config option (using the forge config annotation)

![](https://i.imgur.com/ma6EW8G.png)

And then checking for the feature where we activate it.

![](https://i.imgur.com/aiJhT3b.png)

Besides that, we also added the new Student model for the library which looks similar to the monk which you saw at the beginning of the post.

> Where I only adjusted the model output to the real output, which is a pain nonetheless.

Another issue I fixed was that people were complaining that request manipulation was only slowly synched to the client.
For that reason, I added functionality to the methods taking care of that on the client side so they don't have to wait for the server to sync the updated data over.

![](https://i.imgur.com/TsXkKiX.png)

I hope you liked this update as much as I did, in this refactor we added an additional 300 lines but in this case we added a lot of additional functionality to the GUI (filtering) and made the code way easier to understand, if you check out my upcoming post you're going to see how much we really earned from this.


#### Pull requests:
https://github.com/ldtteam/minecolonies/pull/3204
https://github.com/ldtteam/minecolonies/pull/3215

#### Repository: 
https://github.com/ldtteam/minecolonies
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 125 others
πŸ‘Ž  
properties (23)
post_id68,650,967
authorraycoms
permlinkminecolonies--some-gui-abstractions
categoryutopian-io
json_metadata{"tags":["utopian-io","development","gaming","technology","programming"],"app":"steem-plus-app"}
created2019-01-10 20:27:09
last_update2019-01-10 20:27:09
depth0
children9
net_rshares150,243,126,931,038
last_payout1969-12-31 23:59:59
cashout_time2019-01-17 20:27:09
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value78.920 SBD
promoted0.000 SBD
body_length4,723
author_reputation86,209,585,215,565
root_title"Minecolonies & Some GUI abstractions"
beneficiaries
0.
weight100
accountsteemplus-pay
1.
weight500
accountutopian.pay
max_accepted_payout100,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (190)
@utopian-io ·
Hey, @raycoms!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
post_id68,655,331
authorutopian-io
permlinkre-minecolonies--some-gui-abstractions-20190110t223457z
categoryutopian-io
json_metadata{"app":"beem\/0.20.9"}
created2019-01-10 22:35:00
last_update2019-01-10 22:35:00
depth1
children0
net_rshares0
last_payout1969-12-31 23:59:59
cashout_time2019-01-17 22:35:00
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length589
author_reputation115,404,361,424,151
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@helo ·
$14.80
- I'm glad you like refactoring and I'm sure others are as well.  ;-)
- Great story telling, you made me wonder what does the student really look like?
- Very few comments in the first pr, much better in the second one.

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/1-2-1-1-1-1-1-).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , , , , , ,
properties (23)
post_id68,655,637
authorhelo
permlinkre-raycoms-minecolonies--some-gui-abstractions-20190110t224552477z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit\/0.1","links":["https:\/\/join.utopian.io\/guidelines","https:\/\/review.utopian.io\/result\/3\/1-2-1-1-1-1-1-","https:\/\/support.utopian.io\/","https:\/\/discord.gg\/uTyJkNm","https:\/\/join.utopian.io\/"]}
created2019-01-10 22:45:51
last_update2019-01-10 22:45:51
depth1
children1
net_rshares27,336,254,400,257
last_payout1969-12-31 23:59:59
cashout_time2019-01-17 22:45:51
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value14.803 SBD
promoted0.000 SBD
body_length717
author_reputation56,812,571,147,832
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (17)
@utopian-io ·
Thank you for your review, @helo! Keep up the good work!
properties (22)
post_id68,761,266
authorutopian-io
permlinkre-re-raycoms-minecolonies--some-gui-abstractions-20190110t224552477z-20190113t150127z
categoryutopian-io
json_metadata{"app":"beem\/0.20.9"}
created2019-01-13 15:01:30
last_update2019-01-13 15:01:30
depth2
children0
net_rshares0
last_payout1969-12-31 23:59:59
cashout_time2019-01-20 15:01:30
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length56
author_reputation115,404,361,424,151
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@chireerocks ·
@raycoms, Keep up this development and hope that you are enjoying this **Gaming Development**. Stay blessed. πŸ™‚
πŸ‘  
properties (23)
post_id68,660,038
authorchireerocks
permlinkre-raycoms-minecolonies--some-gui-abstractions-20190111t010847671z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit\/0.1","users":["raycoms"]}
created2019-01-11 01:08:51
last_update2019-01-11 01:08:51
depth1
children0
net_rshares543,972,584
last_payout1969-12-31 23:59:59
cashout_time2019-01-18 01:08:51
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length110
author_reputation26,846,575,075,263
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@elmoncho ·
Muy buen trabajo amigo felicidades suerte sigueme o dame un boto es un buen blog sigue asi :D
πŸ‘  
properties (23)
post_id68,665,764
authorelmoncho
permlinkre-raycoms-minecolonies--some-gui-abstractions-20190111t043017109z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit\/0.1"}
created2019-01-11 04:30:27
last_update2019-01-11 04:30:27
depth1
children0
net_rshares290,690,434
last_payout1969-12-31 23:59:59
cashout_time2019-01-18 04:30:27
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length93
author_reputation2,187,761,623
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@bestjoni2018 ·
upvote me https://steemit.com/photography/@bestjoni2018/bangladesh-cricket
properties (22)
post_id68,665,999
authorbestjoni2018
permlinkre-raycoms-minecolonies--some-gui-abstractions-20190111t043955924z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit\/0.1","links":["https:\/\/steemit.com\/photography\/@bestjoni2018\/bangladesh-cricket"]}
created2019-01-11 04:40:03
last_update2019-01-11 04:40:03
depth1
children0
net_rshares0
last_payout1969-12-31 23:59:59
cashout_time2019-01-18 04:40:03
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length74
author_reputation-2,664,130,874
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-plus ·
SteemPlus upvote
Hi, @raycoms!

You just got a **8.15%** upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in [here](https://steemit.com/@steem-plus) to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
properties (22)
post_id68,671,447
authorsteem-plus
permlinkminecolonies--some-gui-abstractions---vote-steemplus
categoryutopian-io
json_metadata{}
created2019-01-11 08:21:33
last_update2019-01-11 08:21:33
depth1
children0
net_rshares0
last_payout1969-12-31 23:59:59
cashout_time2019-01-18 08:21:33
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length434
author_reputation99,235,409,613,209
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@arcange ·
Congratulations @raycoms!
Your post was mentioned in the [Steem Hit Parade](https://steemit.com/hit-parade/@arcange/daily-hit-parade-20190110) in the following category:

* Pending payout - Ranked 9 with $ 82,19
properties (22)
post_id68,688,075
authorarcange
permlinkre-minecolonies--some-gui-abstractions-20190110t174510000z
categoryutopian-io
json_metadata{}
created2019-01-11 16:47:09
last_update2019-01-11 16:47:09
depth1
children0
net_rshares0
last_payout1969-12-31 23:59:59
cashout_time2019-01-18 16:47:09
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length212
author_reputation140,532,825,392,812
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@umneet ·
Niccee post written by you
properties (22)
post_id68,691,497
authorumneet
permlinkre-raycoms-minecolonies--some-gui-abstractions-20190111t182930244z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit\/0.1"}
created2019-01-11 18:29:33
last_update2019-01-11 18:29:33
depth1
children0
net_rshares0
last_payout1969-12-31 23:59:59
cashout_time2019-01-18 18:29:33
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length26
author_reputation2,193,366,020
root_title"Minecolonies & Some GUI abstractions"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000