package com.earth2me.essentials.antibuild; import java.util.EnumMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild { private static final Logger LOGGER = Logger.getLogger("Minecraft"); private final transient Map settingsBoolean = new EnumMap(AntiBuildConfig.class); private final transient Map> settingsList = new EnumMap>(AntiBuildConfig.class); private transient EssentialsConnect ess = null; @Override public void onEnable() { final PluginManager pm = this.getServer().getPluginManager(); final Plugin essPlugin = pm.getPlugin("Essentials"); if (essPlugin == null || !essPlugin.isEnabled()) { return; } ess = new EssentialsConnect(essPlugin, this); final EssentialsAntiBuildListener blockListener = new EssentialsAntiBuildListener(this); pm.registerEvents(blockListener, this); } @Override public boolean checkProtectionItems(final AntiBuildConfig list, final int id) { final List itemList = settingsList.get(list); return itemList != null && !itemList.isEmpty() && itemList.contains(id); } @Override public EssentialsConnect getEssentialsConnect() { return ess; } @Override public Map getSettingsBoolean() { return settingsBoolean; } @Override public Map> getSettingsList() { return settingsList; } @Override public boolean getSettingBool(final AntiBuildConfig protectConfig) { final Boolean bool = settingsBoolean.get(protectConfig); return bool == null ? protectConfig.getDefaultValueBoolean() : bool; } }