BKCommonLib
BKCommonLib is no longer being updated on dev.bukkit.org.
If you want to use the latest version, use spigot.
Latest version: 1.57
CraftBukkit/SportBukkit/Spigot/MCPC+ build: CB 1.6.4 R1.0 / CB 1.6.4 R2.1 / Spigot 1.7
Older builds available: CB 1.5.2-R1.0 / CB 1.6.2-R1.0
Tekkit: Untested and thus unsupported, some features may not work as expected
Description
This utility library shares all the common code needs for various plugins, and having them in one library heavily reduces the amount of duplicated code. The featured utilities are varied, and whenever something is missing in Bukkit, it is added in BKCommonLib. This is one of the reasons why it has become this large: there are simply a lot of things Bukkit doesn't (want to) offer.
BKCommonLib has versioning on a per-plugin basis, so when a certain plugin needs version 2, and version 1 is installed, the server owner is automatically notified and the plugin is not enabled. This prevents the common mishaps with outdated BKCommonLib versions.
Other than utilities and services, this library offers a wide variety of reflection and user-friendly ways of accessing net.minecraft.server. If your plugin requires the use of the internals, but do not want to risk changing field and method names, you can depend on BKCommonLib to provide them for you. This allows you to remain compatible between CraftBukkit versions automatically, and reduces silent failure hazards.
Reasons for you to depend on this library
- You need to access Minecraft internals in your plugin, and Bukkit has no API for it
- You are tired of re-uploading the same version over again because of the internals changing
- You want to work with Vector/math logic, or need to use other utility classes
- The YAML of Bukkit dislikes you, and you want this to be easier
- You want to easily read and write configuration/data files
- You want easy access to data conversion utilities to convert user input
- You want to work with inventories in an advanced fashion
- You want to work with unique server events
- You want to alter entity behaviour (such as handling block collisions, custom movement, etc.)
- You want plugin messages/permissions to be configurable
- You want to work with (async)tasks without storing IDs
- You want to send and manipulate packets
Features
- General
- PluginBase for easy access to metrics, permissions, localization and more
- Permission defaults for storing the permissions a plugin uses
- Localization for making the messages of a plugin configurable
- Utilities
- General utilities for String, Logic, BlockFace and Math operations
- Block utilities for Block-related operations (states, data, etc.)
- ItemUtil for Inventory, Items and Item Transfer utilities
- RecipeUtil to work with crafting and furnace recipes
- Various Collections for auto-filtering, converting and even interpolation
- Data storage
- Configuration API with nodes, headers and other goodies
- NBT API designed after the configuration API
- (Compressed)DataReader/DataWriter to read and write data from/to file
- Entities
- CommonEntity implementations with added utilities
- EntityController for altering entity behaviour
- EntityNetworkController for altering entity network logic
- Services
- Metrics for keeping track of plugin statistics
- Conversion for conversions between all types of data
- Events and Listeners to keep track of changes on the server
- Packet services and API to keep track of packets
- Task class for easier task scheduling
- Scoreboard services to setup scoreboards without criteria
- Tab View service to alter what is shown when players press tab
Getting started
To start using BKCommonLib, you have two options (after adding BKCommonLib as dependency in the plugin.yml):
Include the jar file as a dependency
Like any dependency, keep the jar file somewhere on your computer and add it to your classpath. Nothing special here.
Make a (new) maven project and include it
Add the following repository:
<repository> <id>dj-tcraft repository</id> <url>http://ci.dj-tcraft.nl/plugin/repository/everything/</url> </repository>
And the following dependency (may need to update version):
<dependency> <groupId>com.bergerkiller.bukkit</groupId> <artifactId>BKCommonLib</artifactId> <version>1.54-SNAPSHOT</version> <scope>provided</scope> </dependency>
Dependencies BKCommonLib uses
BKCommonLib supports various other plugins and projects. Below all of these are listed:
- Vault - for permission plugin support
- ProtocolLib - to avoid packet listening conflicts
- Showcase(Standalone) - to ignore showcased items
- HyperConomy - to ignore shop items
- BleedingMobs - to ignore particles
- CGLib - for generating nms.Entity classes on-the-fly to supply Entity Controllers
- Objenesis - for generating classes without calling constructors (needed for various fixes inside class constructors)
Plugins that require BKCommonLib to be installed:
Disclaimer
This plugin utilises Hidendra's plugin metrics system, which means that the following information is collected and sent to mcstats.org:
- A unique identifier
- The server's version of Java
- Whether the server is in offline or online mode
- The plugin's version
- The server's version
- The OS version/name and architecture
- The core count for the CPU
- The number of players online
- The Metrics version Opting out of this service can be done by editing plugins/Plugin Metrics/config.yml and changing opt-out to true.
License
This library uses an open license. Feel free to use whatever code you need from it, you do not have to ask me either. If you want me to add certain features, that is fine too. Everyone is allowed to use this Library as a dependency. I do recommend extending 'PluginBase' instead of 'JavaPlugin' then, as it allows you to automatically deal with the BKCommonLib versioning checks. See also: BKCommonLib license file
This product includes software developed by the Apache Software Foundation (http://www.apache.org/)
Links:
Compatibility
BKCommonLib supports ProtocolLib when it is enabled, but if it is not, the player connection is replaced resulting in several incompatibilities. To fix these incompatibility issues, install ProtocolLib next to BKCommonLib. This can not be stressed enough. When incompatibility occurs, BKCommonLib will notify you in the console and will disable itself. The following plugins are known to be incompatible when ProtocolLib is NOT installed:
Metrics
This plugin sends server count and dependency statistics to MCStats.org. You can (globally) opt out in the PluginMetrics/config.yml file.
Banner
I use a banner in my depending plugins. This banner is automatically updated when a new version of BKCommonLib is out. It is a quick and efficient way to keep track of updates for this library. This was needed, too, because a lot of people were using outdated BKCommonLib versions, which resulted in bug reports...too many of them. And I do not want to waste your time with invalid reports. You have a plugin that uses BKCommonLib? Feel free to use the banner on your download page.
[[http://dev.bukkit.org/bukkit-plugins/bkcommonlib/|{{http://ci.dj-tcraft.nl/job/BKCommonLib/lastSuccessfulBuild/artifact/target/BKCommonLibVersion.png|Go to the BKCommonLib Dev-bukkit page}}]]
@KamikazePlatypus
Put into IDE of your choice, add dependencies then compile.
@bubba1234119
How would you compile it without Maven?
@giezenberg
I've got most of it anyways, thanks though. As for maven I despise maven so I will not be using it.
Stack trace as of now: http://pastebin.com/9pU729qh
@bubba1234119
I can get you a big part of the other half :) Gonna get a pull request ready soon, and also mavenise your project. Because thats way easier :)
@carmeops
Same :D!
Got about half of the reflection errors out of the way, the full stack trace has went down by about half.
http://pastebin.com/1ktJtwsB
When I am done updating BkCommonLib I will move onto making sure TrainCarts works with it.
Edit: Went through Train Carts, MyWorld and Sign Link. It looks like they all work out of the box on 1.8. However in case they don't I built them and they are under the releases on my github.
@giezenberg
this comment section can't even handle my partying right now \o\ \o/ /o/
@carmeops
Yes, but don't hype to much :)
@giezenberg
am i allowed to embark on the hype train now? \o/
@Swords761
I uploaded a compiled version to my github. If any of the authors of BKCommonLib have a problem with it I will take the releases down.
https://github.com/bubba1234119/BKCommonLib/releases/tag/v1.60
Edit: My pom.xml uploaded to my github is not updated so it will not work to compile.
@bubba1234119
It might just be a better idea if you upload the compiled jar somewhere (with lenis' permission, of course) so it'd be easier for end-users to bugtest. I'm not used to trying to compile such a beast of a plugin so I'm struggling to figure out how to myself, and I'd like to think of myself as somewhere in-between an expert administrator and novice developer. That's most likely higher than the skill level for many of the people who have commented here this past month asking for an update, so I doubt they'll figure it out themselves anytime soon either.
(btw I did try editing the pom.xml myself but every time I go to update the project it spits out a snapshot from before you made any updates and I cannot figure out why...)
@Swords761
That is a good possibility, I however am not compiling it as a maven project.
A lot of the repos however are not there so it will not work unless the pom.xml file is edited.
@bubba1234119
I'm trying to build it as a Maven project using the pom.xml and it's having all sorts of issues since that was left untouched; that might be how Platypus is trying to compile as well.
@KamikazePlatypus
I compiled with spigot, I didn't use anything out of the the libs folder.
If you take my fork and download it you should be able to get it to compile.
@bubba1234119
How did you get it to run? I compiled it using the included Spinot jar, but whenever I try to run it, it says it is incompatible with Spigot 1.8. I'm trying to run it for testing purposes, I know it spits errors.
@giezenberg
Yea no kidding, I have my repo to the point where it now compiles. Here is the stack trace if anyone is interested: http://pastebin.com/D9kf8ddt
Also here is my repo: https://github.com/bubba1234119/BKCommonLib
For anyone feel free to fork it, submit changes etc.
@bubba1234119
I got also pretty far with updating the NMS code, only does it cost a hell lot of time to finish my work :(
I did quite a bit over at my fork here: https://github.com/bubba1234119/BKCommonLib
Going to try to do more but I am not very familiar with nms code.
Edit: Approximately 3% of the plugin to update, then testing will have to be done.
@lenis0012
Spigot's versioning package for Spigot or the Minecraft Server code?
@lenis0012
Already looked at https://hub.spigotmc.org/stash ?