New scripting language support: Java

Started by maxorator, Apr 02, 2016, 10:11 PM

Previous topic - Next topic


Thank you!

One small sugestion, which would come in handy is the addition of a new utility method to the generic Entity implementation ( and ) and that is a getDataOrDefault method. This is usually a common method in API's that deal with Object and the possible presence of null. The syntax would be something like:

getDataOrDefault(String name, Class<T> klass, Object defaultValue)

And the idea here is that if the value/data that it's retrieving is null, it would return the default value instead, the one that's being passed as a parameter.

I took a look at your and this is what I had in mind:
    public <T> T getDataOrDefault(String name, Class<T> klass, Object defaultValue) {
        synchronized (sync) {
            if (data == null) {
                return null;

            Object value = data.get(name);

            if (klass.isInstance(defaultValue) && value == null) {
                return (T) defaultValue;
            } else if (klass.isInstance(value)) {
                return (T) value;
            return null;
Not something super urgent, but it'll surely help writing cleaner code in the future and avoid all those pesky null checks :-X


Quote from: BABA1 on Apr 12, 2016, 05:06 AM
Quote from: NewK on Apr 11, 2016, 10:01 PM@maxorator I've noticed that Player does not have a IsFrozen property similar to the Squirrel plugin, has this not been implemented yet or is this done differently with this java plugin?

New pro static void functions have been med. :D
This is not a static function.
This isn't a bump btw


@maxorator  2 things I've noticed:

- the onPlayerCrashReport event seems to be missing. I noticed the function is there on the plugin but it's just not implemented, something you forgot maybe?

- Also noticed a really nasty bug on the data hashmap in It would seem that sometimes the data hashmap is passed with previous data to completely new entities. For instance, if I create a new pickup with "server.createPickup(etc..)", and  attach data to it with .setData("test", "blabla.."). If I delete that pickup and create a completely new one with "server.createPickup(etc..)" sometimes this new pickup will have the data that I attached to the old one I deleted. Like if I do newPickup.getData("test", String.class), I will get "blabla..". Kinda hard to reproduce this bug but I believe it's an easy fix if we clear the data hashmap every time a new entity is created.

Seeing that maxorator is inactive, I've fixed both of these issues and decided to share the fixed versions publicly for anyone else that's thinking about doing java server development. Binaries can be found below:

Plugin (only 64bit builds for now) :
Integration jar :

The integration.jar is to be used with tools-0.1.2.jar which you can find on thijn's maven server here 


New update released

Fixed VehicleImunity and PlayerImunity classes always returning true when using the has() method. And implemented the onServerPerformanceReport event. This is not a new vcmp event, it's been on the server quite some time, its just not implmented for the squirrel plugin. The event has the following signature:

onServerPerformanceReport(int entry, String[] descriptions, long[] times)
This event is automatically called every 30 seconds by the server and can be used as a way to monitor server performance. It will return a number of descriptions for various server "phases" and the amount of time (in microseconds) spent on each of those phases in the last 30 seconds. So you can check what's taking the longest for the server process, vehicles, pickups, players, etc...

The available phases are:
  • Streaming
  • Vehicle proximity checks
  • Processing players
  • Processing vehicles
  • Processing pickups
  • Processing objects
  • Packet processing
  • Plugin frame event


- Plugin :
- Integration jar:


A server crashing bug has been fixed on the Pickup#isAutomatic()  method. Make sure to update your server plugin to this latest version. Otherwise your server will crash when using that method.

Plugin download: here

This fix did not require any changes to the integration .jar so you just need to download the plugin .dll/.so and replace it with the one on the plugins folder.


The plugin is now compatible with Java 9 and above. Just download the integration.jar from HERE and replace it with the old version.

Reminder that even though the plugin is now compatible with newer Java versions, some of the libraries you're using may not be. So if you get any errors when starting the server make sure the libraries you're using are compatible with the Java version you're using.


  • Fixed player.GetPlayerWeaponAtSlot and player.GetPlayerAmmoAtSlot always returning 0
Plugin download: here


  • New update adds support for Java agents
Plugin download: here


  • Fixed server.getCoordBlipInfo() never returning null when looking for non existent blip
Plugin download: here


The integration .jar and tools.jar are now deprecated.

I created a new project called vcmp-integration.jar. This project includes both tools.jar and integration.jar in one single jar. So from now on you only need to use 1 jar file. The repository is located on gitlab

The artifact was also uploaded to gitlab's maven server so you can now use it automatically with maven/gradle without needing to do any installs on your local maven. To use it in maven add the following to your pom.xml file:

Add the gitlab maven repository:


Add the dependency:
That's all.

If you need to access the .jar file directly you can download it from here: Click on the version you want,  then scroll down and click the .jar file.

This .jar is fully backwards compatible and is just a drop-in replacement for tools.jar and integration.jar, you won't need to change anything in your code.


Great! this is helpful, thanks for sharing.