Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning
titleDeprecated!

The old API is deprecated from 1.0.0, please use the new API.

 


What changed?

We focused for the 1.0.0 release at making ViaVersion multiplatform compatible. This also meant we had to change the way ViaVersion and the api worked,

 


The class ViaVersion is deprecated, by usages like ViaVersion.getInstance() use Via.getAPI() inteadinstead.

Maven

ViaVersion provides a Maven repository that you can use to implement the ViaVersion API inside your project.

...

Code Block
languagexml
titleViaVersion Maven repository
<repository>
    <id>viaversion-repo</id>
    <url>https://repo.viaversion.com</url>
</repository>

 


Dependency:
Code Block
languagexml
titleViaVersion Maven dependency
<dependency>
    <groupId>us.myles</groupId>
    <artifactId>viaversion</artifactId>
    <version>LATEST</version>
</dependency>

...

ViaVersion provides an API for developers to use the new BossBar for 1.9 players and higher.

 


Example BossBar usage:

Code Block
languagejava
titleBossBarExample.java
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.ViaVersionAPI;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;

public class BossBarExample extends JavaPlugin implements Listener {
    private BossBar bossBar;

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this); // Register Bukkit events

        ViaAPI api = Via.getAPI(); // Get the API
        bossBar = api.createBossBar(
                "Hi! This BossBar is created using the ViaVersion API!", // BossBar title
                1F, // Boss health (Float between 0 and 1)
                BossColor.BLUE,  // BossBar color
                BossStyle.SOLID); // BossBar Style
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
		// When we added the BossBar, we supported addPlayer with a Player object, that is deprecated since 1.0.0. 
		// Get the player UUID instead.
        bossBar.addPlayer(e.getPlayer().getUniqueId()); // Show the BossBar when a player joins 
    }
}
Preview:

 


Info
titleSide note

Our API will not give 1.8 players a BossBar for the people that use 1.8-1.8.8.

Spigot provides an API for everyone that uses Spigot 1.9 and higher. We recommend you to use that one if you are using Spigot 1.9 or higher.

...