JCore
JCore
What is it?
JCore is a land management, economy, and chat API. It's main part is the land management.
For Server Owners
Plugins may use this plugin to limit their plugins functionality to specific areas. One example is towns. The plugin store the land data in highly compressed binary files. That way you can use a lot of land without the data file growing out of control. A chunk is at maximum 1272 bytes, that means that one Gigabyte is roughly 800 000 chunks. If each player want's an area of 500x500 blocks then it would be enough for more than 800 players.
JCore is also a special purpose Webserver. It can display info from the plugins on your server, it can also let you change the settings on it. All players needs to create a login first, before they can set any settings. Normally you only need a normal http connection, but if you a running a larger server and want a http secure connection (or https), you can enable that, but it does require a valid certificate.
JCore runs best (but it doesn't require) with a database connected to it. On the first start the plugin will run you through a installation wizard in order to install MySQL community server. If you already have a database or want to install another one you have the option to use that instead. Some plugins that relies on JCore might not work without a database.
It does also makes it more simple for plugins and for you to add more language. Plugins may add their own languages (Everyone must support English, more specific en-US), and you can also easily modify a language if you want to from any plugin using this JCore's language handler. You can set a default language for the server, and if you want to players may also set their preferred languages for themselves. This is done by players with simple commands like /lang en-US or like /english, or /svenska. For languages that have difrent versions. Like english which have both American english and Enland english and Australian english, you just specify the region after the command, like /english australia, by default if no region tag is specified it will go after the most popular region. In this case America.
For Developers
JCore basicly limits the events so that events are only fired to those plugins that owns the land that the event is fired from. For example when a BlockPlaceEvent is fired it will directly send it to the land area(In the plugin referred as Collection) that the block was placed in. Other "Collections" will not receive that event. The event can also be passed to a plot within the collection. For simplicity the plugin does also contains all you need for currency, so there is no need to link with Vault or a currency plugin, JCore does that for you. The same applies to chat. JCore does also have functions to make the localization of your plugin much easier. You will be able to reach the world with ease. It does also comes with easy functions to handle SQL. You should see this plugin as a set of tools. You might not want to use the land management, but instead you want to use the SQL functions.
Useful links
Questions
Is it very storage consuming?
Well that depends. A chunk is at maximum 1272 bytes, that means that one Gigabyte is roughly 800 000 chunks. So if you intend to claim like 80 million chunks you might start getting problems. Note that area claiming is freeform so a chunk might be smaller than 1272 byte.
Is it very ram consuming
That is optional, the plugin has a land cache. You can configure how many chunks that can at most be contained within it. A chunk is 1272 bytes at most. Note that it takes a little more data while in the ram, but not more than a few bytes extra. The cache does also contain a list of the coordinates of all chunks contained in the save file. This list can't be configured, and it most be there for good efficiency in the cache (It's pointless to search the file for a chunk that isn't there anyway). The size of that list is exactly the amount chunks in the save file time eight. So a file with 800 000 chunks will return in a list that is 64 megabytes big.
Does the plugin creates lag?
Not that I'm aware of. It depends totally on the plugins that use it. It doesn't use any events by itself, it only passes them to the plugin that owns the area that the event was fired from. The saving is handled in it's own thread, and does not interfere with the main minecraft thread in any way. On shutdown there might be a delay while its saving, if a lot of area is claimed it might take a few seconds. If the server is under heavy load when it starts the save thread, it might be possible that a slight lag might show. Note that a save thread is not very CPU consuming. The speed of the saving is most often limited to the speed of your hard drive, a modern SSD drive will make the saving go much faster than an old SATA drive.
Permissions
There is only a very few permissions. Most of the commands must be done from the console. And the commands is basically to remove collections, cleaning maps and stuff like that.
Developer Section
Backwards capability with old plugins
What if I have made a plugin and want this to work with JCore. Do I need to totally rewrite the plugin? Well in most cases you can just make another plugin the gives the player the permission needed to use the plugin based on his current location. Lets say that you have made a world edit plugin. And you want it to only be used inside the specific collection. Then you can simply just give the permission necessary to use it when the players enter the collection, and then remove it when he steps out.
The plugin hierarchy
Here is a illustration of how JCore fits between your plugin and Bukkit.
As you can see, JCore doesn't cover the entire Bukkit API. That's since its doesn't replace all bukkit functions, just some of them. Mainly the event handling. Your plugin should still extend JavaPlugin, and it should be set up as a normal plugin except when it comes to the events that has with land area to do. Instead of adding a listener to Bukkit your plugin should create a collection and add it to JCore.
The relation between the classes handling the land is shown here:
How do I add my plugin to the language feature?
It's almost to easy actually. When you call any of the Lang class methods your plugin will be added. That does mean that the first message your plugin sends may take a second longer than the others. But who cares. Your plugin must however put all its ".lang" files inside a folder called "lang" inside it's .jar package. Your plugin must also follow a certain pattern inside the lang file, but that pattern is also very simple. The file names of the ".lang" files must follow the IETF language tag standard with one region subtag, for example en-US, en-EN, and sv-SE. Your plugin can only use languages that JCore supports, a list of all supported languages will be uploaded together with the release.
Plugin Metrics
The plugin uses MCStats.org to collect interesting information about the plugin. For example how many servers that are currently using it. It is a VERY small task, and you shouldn't even notice the difference from having it turned on or off. You may if you want, turn it off, but it would be more fun for everyone if you let it be on.
The landmanagement part is going to be 100% rewriten in order to integrate with the blockstorage and entity storage. That way you can by the blockstorage know if the block belongs to a protection or not. You can also know if a entity is inside a protected area.
I am back from vecation now. And i have now started working on some new saving systems. Its a system that saves data for blocks and entities. However unlike the quickstorage this data cant be accessed through a database since it will always be saved as a flatfile. However it will suport both private and global storage. You can also save as many strings or numbers as you want.
You acces the storage this way:
BlockStorage blocks = Storage.get(Block block);
or this way
EntityStorage entitys = Storage.get(Entity entity);
Blocks may also be accessed through its coordinates, and entities through its UUID. When you has the storage you can easily set values in a similar way as hashmaps, except that it only allows numbers and strings.
Hi joatin, do you have some good news about your JCore ?
Thank you
The way of implementing JCore has changed. Instead of getting the plugin through the plugin manager and cast it to jcore and then call the hook() method you do now instead you subclass the JCoreExtension class. That class is a subclass of JavaPlugin but it adds some additional functions and it makes the interaction with JCore much easier. In fact you won't even notice that you are interacting with another plugin.
Some good stuff that the class brings are the SQL class. Well, I guess you can figure what that does. Another nice method is the sendDebug(String message). It sends a message only if the server is in debug mode. Its good when you are building your plugin.
Parts of the SQL api has now been done. You don't need any knowledge about SQL. All that might be good is the understanding of how a table looks. But thats all. The plugin does autamtically puts you in the right schema and all your data is private. There is also however the global data there you can put data that can be shared with any plugin. There is also besides tables the Quick storage. You acces that in the exact same way as a hashmap, put and get. The key however must be a string, and the value must either be a string or a primitive. By default having a database connected to JCore is optional, but a plugin can tell jcore that it requires a database. In that case JCore will run the user through a tutorial on how to set up a database, and the user may optionally choose to let JCore run the mySQL Community database set up for you. On first start JCore will run this tutorial as well. A database is always a plus. But JCore itself doesnt require a database. It can store all data in regular flatfiles.
JCore does also provide a new function called PlayerData. In player data any plugin can put data it wants to save. The data it wants to put must either be a string or a wraped primitive. The data can be either private ot global, global data can also be protected from changes from other plugins.
After thinking for a while I come up with a function for the plugin to install a database for you automatically. Through a simple command it might be possible to install MySQL directly. (Only useful in small community servers)
How is the land management going?
It's going great, it's almost done actually. Right now im working on something called "BlockEditMode" which is a way to visualize the blocks that are within a Collection or plot, and to show which blocks that are marked for addition or removal.
Well I got the http secure connection to work. However a SSL connection does always require a certificate, and those certificates does often cost. So therefor there will always be a option to use normal http instead of https. The downside with http is that the passwords are unencrypted and can therefor be stolen. But if you are running a small server that shouldn't be any problem.
Well so far it works perfectly for a web client (in my case Internet Explorer 10) to download the main page together with all necessary stylesheets and javascripts.
The license permits the use of bootstrap, so we might see some plugins with cool websites soon. But how "Cool" will it actually be? Well one thing is that all platforms will be supported from iPhones to very large computer screens. Another is animations. Another one is live updated data.
But noone has ever done this before! You're doomed to fail! Well someone must be the first. If people wouldn't tried to make their weird ideas come true we wouldn't have computers today and no bukkit.
I have been looking into a project called bootstrap. Its a library of css scripts and some javascripts. My plan is to make make plugins manageable from a webpage and not just through ingame. I must look inte their license if this is possible, also I haven't yet get it to work to establish a secure http connection (or a https connection) with a webclient. There is probably a line I forget somewhere. Note that this is highly experimental, and might never actually be included. But I thought it could be fun to let the followers of this plugin know.
Maybe I should make a twitter page for my development.
I hope that this will be the start for the second gen plugins that have their effect applied based on the land instead of world. The plan is that all plugins offering this will have support for multiple languages, and support for SQL, all kinds of databases.
Yes, I will maintain it, and I will expand it with lots of tools that makes programming simpler. On your other question, yes ofcourse you may fork this. The project is under the BSB License which simply means that do whatever you like with it, but don't forget proper credits. I'm looking forward for some good contribution to this project ;) there will always be work to do, so if your bored and have nothing to do, just ask me.
Thanks joatin i plan to take a look at your plugin and JTown, JProtection also.
I would like to know if you're planning to maintain it and if i can fork this projects on GitHub ?
Thanks a lot and i'll be back to tell you my experience with them.
All methods in Economy, Permission, Chat, and Language are now 100% thread safe.
The economy api is almost done. Except the basic functions for handling money, like deposit and withdraw, you can also manage banks. You can for example add bank members, change the name if a bank and a lot more. However not all ecenomu plugins support this. If a plugin does not support a method, it will throw an notsupportedexception. You can simple catch that exception with a try clause.
Vault was now removed from the plugin. Since the plugin supports all plugins that vault does, it was considered unnecessary.
I have made the API for the chat and economy to look similar to vaults, so that it will be easier for developers to use this as well. Vault is also a very well formed API so that's also a reason why some methods are exactly the same. However you will find some more useful commands, and you will find some removed, mostly due to the system behind it.
Passed 8 000 lines of code today. The language feature is now working. You can also create new databases and tables with SQL. When those two parts are complete together with the Economy and Chat, it might be time for the first alpha. The land management might take a little longer since its a little complicated.
The first one will probably be my own plugin JTown. From the beginning this plugin was JTown, but as it grew larger I decided to split JTown into two parts. This is the part with all the goodies. A good thing with this plugin is that it brings so much together. It makes localization much easier, makes it much easier to use SQL, and similar to Vault it brings chat and economy to one place.
Interesting.... Awaiting the practical plugins using it :)