Implement config to the API

This commit is contained in:
Hugo Kerstens 2016-03-22 16:53:53 +01:00
parent ccb2a4756f
commit 147891f76b
3 changed files with 48 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.ViaVersionAPI; import us.myles.ViaVersion.api.ViaVersionAPI;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.api.boss.BossBar; import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor; import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;
@ -42,7 +43,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI { public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVersionConfig {
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>(); private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
private boolean debug = false; private boolean debug = false;
@ -324,6 +325,10 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
return getConfig().getBoolean("bossbar-anti-flicker", false); return getConfig().getBoolean("bossbar-anti-flicker", false);
} }
public boolean isUnkownEntitiesSuppressed() {
return getConfig().getBoolean("suppress-entityid-errors", false);
}
public double getHologramYOffset() { public double getHologramYOffset() {
return getConfig().getDouble("hologram-y", -1D); return getConfig().getDouble("hologram-y", -1D);
} }

View File

@ -2,10 +2,17 @@ package us.myles.ViaVersion.api;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import us.myles.ViaVersion.ViaVersionPlugin;
public class ViaVersion { public class ViaVersion {
@Getter @Getter
@Setter
private static ViaVersionAPI instance; private static ViaVersionAPI instance;
@Getter
private static ViaVersionConfig config;
public static void setInstance(ViaVersionPlugin plugin) {
ViaVersion.instance = plugin;
ViaVersion.config = plugin;
}
} }

View File

@ -0,0 +1,34 @@
package us.myles.ViaVersion.api;
/**
* Created by Hugo on 22/03/2016.
*/
public interface ViaVersionConfig {
/**
* Obtain if global debug is enabled
*
* @return true if debug is enabled
*/
boolean isDebug();
public boolean isPreventCollision();
public boolean isNewEffectIndicator();
public boolean isSuppressMetadataErrors();
public boolean isShieldBlocking();
public boolean isHologramPatch();
public boolean isBossbarPatch();
public boolean isBossbarAntiflicker();
public boolean isUnkownEntitiesSuppressed();
public double getHologramYOffset();
public boolean isAutoTeam();
}