[Open Source] SkyBlock Minecraft Addon [New features #3]

in #utopian-io6 years ago (edited)

junglegui.jpg

Hello steemians and minecraft players,

today, I want to show you everything new since the last post I made. This time, many administration and moderation commands were added to the game to give server operators some tools to use. Like everything in this SkyBlock add-on to Minecraft, you can do whatever you want with it, since it is licensed under the MIT license.

1. Repository

https://github.com/Abwasserrohr/SKYBLOCK.SK

2. Index

  1. Repository
  2. Index
  3. New Features
    3.1. Biome changing addon
    3.2. Admin commands
    3.2.1. /isadmin island invite <owner> <new player>
    3.2.2. /isadmin island changeleader <new leader>
    3.2.3. /isadmin island changebiome <new biome> [<leader>]
    3.2.4. /isadmin island kickall
    3.2.5. /isadmin island addmember <player>
    3.2.6. /isadmin island calc <leader>
  4. Pull requests
  5. GitHub Account
  6. How to contribute

3. New Features

This time, only new features have been added to the game. Currently, there is only one non-critical bug to fix which might take some time, since the people want new features and asking every day, why it takes so long to make it, I'll try to add new features first and then (once i'm done with most parts) more into fixing bugs.

3.1. Biome changing add-on

I hoped that i don't need to create a biome changing add-on myself, since there are already a couple of ready to use plugins which allow this sort of functions. But it turns out, most of them are either aren't free, outdated or bring some heavy functions and dependencies with them, we simply don't need.

That's why i created the biome changing add-on, it took some time to turn everything together and learn how this process works, but after completing it, i'm sure it was worth it to add it directly into the game, since server operators now don't have to wait until the other plugins are ready to do this.

biomeexample.jpg

Now, lets get into this:

The add-on is a function which can be called on the whole server once it's loaded. This allows me to use the function everywhere i need. It is called "changebiome" and needs three parameters, an offline player (or online), the name of a biome and a text how this biome is called in the language of the player.

These features aren't included directly in Skript, that's why we have to use skript-mirror to get some Java classes from bukkit, a server tool which is used by many servers.

This is in skript done like this:

import:
    org.bukkit.Bukkit
    org.bukkit.World
    org.bukkit.block.Biome

Then it is time to create the function, I called it "changebiome", since this makes sense and explains in itself what it does.

function changebiome(player:offline player,biome:text,title:text):
    set {_uuid} to uuid of {_player}

To make future variables shorter, i always try to use the {_uuid} variable, which takes some complexity of the variables.

    set {_l::1} to {SB::player::%{_uuid}%::island::border1}
    set {_l::2} to {SB::player::%{_uuid}%::island::border2}
    set {_l::1} to location at x-coord of {_l::1}, 0, z-coord of {_l::1} in world "%world of {_l::1}%" parsed as world
    set {_l::2} to location at x-coord of {_l::2}, 0, z-coord of {_l::2} in world "%world of {_l::2}%" parsed as world

Here, I took the two borders of the player's island and then created new borders, which both only are on the y-axis 0. This makes the process later less resource intensive.

    set {_world} to Bukkit.getServer().getWorld("%{SB::config::world}%")
    replace all "_" with " " in {_biome}
    set {_changebiome} to {_biome} parsed as biome

Here the worlds and biome are defined in as valid and usable variables. We can't simply use the world name in the {_world} variable, but rather a unique id for this world, which is created with Bukkit.getServer().getWorld("name of the map")

Then we replace all "_" with " " and then parse it, this saves some time, since Skript already has a function for that.

    set {_blocks::*} to blocks within {_l::1} to {_l::2}
    set {_size} to size of {_blocks::*}
    delete {_blocks::*}

To make it more visually appealing, i added some sort of loading bar to this process. Since we have to change the biomes block by block, it can't change everything at once, also this is better in the main thread. That's why this is necessary in my opinion.

{_size} now has the amount of blocks the add-on has to go trough until it is done.

    set {_a} to {SB::lang::bc::changing::%{SK::lang::%{_uuid}%}%}
    replace all "<biome>" with "%{_title}%" in {_a}
    send "%{SB::lang::prefix::%{SK::lang::%{_uuid}%}%}% %{_a}%" to {_player}

Here, the player is informed about the biome change in the chat window.

    set {_needed} to 0
    set {_progress} to "%{SB::config::color::secondary::2}%||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||&r"

This is the progress bar, which fills up once 1% is done. {_needed} is the current percentage, every time the percentage is over the of {_needed}, the progress bar is being replaced.

    loop blocks within {_l::1} to {_l::2}:
        set {_chunk} to chunk at loop-block

Now, it is going to loop trough all the blocks of the above defined locations, here, the island borders.

        add 1 to {_i}
        add 1 to {_b}

These two variables aren't necessary for the core purpose of this function, but this adds more control and also is needed for the progress bar.

        if {_i} is 100:
            wait 1 tick

Since we're looping trough many blocks in the main thread and don't want to freeze the game because of biome changing, it waits for 1 tick (1/20 of a second) until it continues to prevent lag.

            set {_p} to ({_b}/{_size})*100
            if {_p} >= {_needed}:
                add 1 to {_needed}
                replace all "%{SB::config::color::secondary::2}%|" with "%{SB::config::color::primary::1}%|%{SB::config::color::secondary::2}%" in {_progress}

                execute console command "/title %{_player}% actionbar {""text"":""%{_progress}%""}"

Now, this is the calculation needed to create the progress bar, it calculates the percentage how much it already changed, if the percentage is equal to or higher than the {_needed} percentage, the progress bar gets one | changed into another color. This makes the process more appealing and the user knows that everything works like it should.

            set {_i} to 0

Since this code above here only happens, if the {_i} variable is 100, we set it to 0 here to repeat that every 100 times.

        set {_x} to (location of loop-block).getBlockX()
        set {_z} to (location of loop-block).getBlockZ()
        {_world}.setBiome({_x}, {_z}, {_changebiome})

Here, we get the x and z axis of the looped block and then finally set the biome to the specific block.

    send "%{SB::lang::prefix::%{SK::lang::%{_uuid}%}%}% %{SB::lang::bc::done::%{SK::lang::%{_uuid}%}%}%" to {_player}

Now, this is the last translated message, the player is getting, this tells the player that the process is done.

There are many more files that needed a change for this to fully work, like a new biome store, translation, configuration, etc., everything is within the pull request below.

Direct Link: biomechanger.sk

Pull request: Add biome changer addon #39


3.2. Admin commands

Now I have to say that this isn't something I can show much with pictures. But it really helps the server operator to get things done in an organized way and there are some more commands which might have to be added in the future, but this is the first contribution to the administration commands, which are all within the "/islandadmin" alias "/isadmin" command.

I'll add the pull request at the bottom and only explain what these commands are doing to understand why they are needed.

3.2.1. /isadmin island invite <owner> <new player>

In some cases, the server operator might want to invite players to an island without the owner being online, since it wasn't possible to do this before, with this command, the admin can invite any player who has no island to the island by the specified owner.

3.2.2. /isadmin island changeleader <new leader>

Sometimes, the leader of an island has to be changed, sometimes because one of the two players is no longer active or because some other reasons, it might be needed to change the leader, this can do it.

The admin has to stand on the island where he wants to change the leader and the new leader has also been a member of the island.

3.2.3. /isadmin island changebiome <new biome> [<leader>]

This command allows to change the biome directly using a command. This is nice for admins who want to set up a shop by themselves, they can change every biome available, also "nether" and "the end", if wanted.

The leader is optional, if the server operator (or admin) stands directly on the island, it will be detected in an automated way. But if the admin wants to specify a specific leader, he can do that as well, this also works from the console or for admin shops.

3.2.4. /isadmin island kickall

With this command, everyone on the island, on which the admin is standing, is kicked. This prevents an island delete, since nobody owns the island anymore.

This can also be used to copy islands to new locations, the admin can kick everyone, then copy the island using a WorldEdit tool to another new location and then delete the island later or let it stay there for historical purposes.

3.2.5. /isadmin island addmember <player>

Now, if we have kicked everyone from an island, we can't invite them because we don't have the leader anymore. With this, we can add new members to islands, also empty islands, on which everyone has been kicked.
This is also usable, if no invite is needed and the player should be added without asking them.
If the user gets added using "addmember" on an empty island, the new user gets the leader.

3.2.6. /isadmin island calc <leader>

Sometimes, big changes are made in the configuration. For this reason, it is possible to recalculate the island of a leader new to get valid scores.

Pull request: Add admin commands #40

4. Pull requests

https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/39
https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/40

5. GitHub Account

https://github.com/Abwasserrohr

6. How to contribute

If you want to contribute to this project, just ask Abwasserrohr, the sewage pipe on the discord linked below. You can also create a pull request right away, if you already know how skript works.

I'm really looking forward to find new people to use skript to move the project forward faster. People new to coding are also very welcomed, since skript helps with the first steps in coding. I hope to see you there. =)

Discord: https://discord.gg/FRuK5BC


Thanks for reading this contribution post. This time, I didn't add so much pictures as last time, but I wanted to visualize how the biomes change the look of the default island and that it is very necessary for some people who want to play in the desert or like specific colors more than the normal ones. I also showed the biome menu shop as thumbnail. =)

I really appreciate comments and feedback, I'm also looking forward for new suggestions what should be added next either here in the comments or on GitHub as an issue.

Keep on steeming,

@immanuel94

Sort:  
  • Great post, I like the organisation of it.
  • Plenty of explanations and code examples.
  • Awesome code comments.

Your contribution has been evaluated according to Utopian policies and 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.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks for reviewing my contribution post. =)

Thank you for your review, @helo! Keep up the good work!

cool, gl

Thanks for your comment. =)

Die Biome waren eine gute Idee und wurden auch gut umgesetzt =)

Vielen Dank für das Feedback.^^

Ja, die Biome gehören finde ich einfach dazu. Gerade beim SkyBlock, wo man ja nicht die Wahl hat, wo man sich niederlässt... =)

Hi @immanuel94!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 2.437 which ranks you at #17395 across all Steem accounts.
Your rank has improved 2942 places in the last three days (old rank 20337).

In our last Algorithmic Curation Round, consisting of 239 contributions, your post is ranked at #194.

Evaluation of your UA score:
  • Only a few people are following you, try to convince more people with good work.
  • The readers like your work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server

Hey, @immanuel94!

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 or Steeditor).

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

Vote for Utopian Witness!

Die Biomänderung gefällt mir

Freut mich, dass dir das neue Feature gefällt.^^

Congratulations @immanuel94! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 8000 upvotes. Your next target is to reach 9000 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!