Skip to content

Commit

Permalink
Fix ViaVersion api access
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoenix616 committed Nov 28, 2016
1 parent a109c7a commit 013c3bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.java.JavaPlugin;
import org.mcstats.MetricsLite;
import us.myles.ViaVersion.api.ViaVersionAPI;
import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.ViaAPI;

import java.io.IOException;
import java.util.List;
Expand All @@ -47,7 +48,7 @@ public class WorldResourcepacks extends JavaPlugin implements ResourcepacksPlugi

private InternalHelper internalHelper;

private ViaVersionAPI viaVersion;
private ViaAPI viaApi;
private NewAPI authmeApi;

public void onEnable() {
Expand Down Expand Up @@ -99,9 +100,10 @@ public void onEnable() {
internalHelper = new InternalHelper_fallback();
}

viaVersion = (ViaVersionAPI) getServer().getPluginManager().getPlugin("ViaVersion");
if(viaVersion != null) {
getLogger().log(Level.INFO, "Detected ViaVersion " + viaVersion.getVersion());
ViaVersionPlugin viaPlugin = (ViaVersionPlugin) getServer().getPluginManager().getPlugin("ViaVersion");
if(viaPlugin != null) {
viaApi = viaPlugin.getApi();
getLogger().log(Level.INFO, "Detected ViaVersion " + viaApi.getVersion());
}

if (getConfig().getBoolean("autogeneratehashes", true)) {
Expand Down Expand Up @@ -432,8 +434,8 @@ public boolean checkPermission(UUID playerId, String perm) {
public int getPlayerPackFormat(UUID playerId) {
Player player = getServer().getPlayer(playerId);
if(player != null) {
if (viaVersion != null) {
return getPackManager().getPackFormat(viaVersion.getPlayerVersion(playerId));
if (viaApi != null) {
return getPackManager().getPackFormat(viaApi.getPlayerVersion(playerId));
}
return serverPackFormat;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</modules>

<properties>
<plugin.version>1.6.11-SNAPSHOT</plugin.version>
<plugin.version>1.6.12-SNAPSHOT</plugin.version>
</properties>

<repositories>
Expand Down

0 comments on commit 013c3bb

Please sign in to comment.