类org.bukkit.configuration.Configuration源码实例Demo

下面列出了怎么用org.bukkit.configuration.Configuration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ExploitFixer   文件: PacketsModule.java
final public void reload(final Configuration configYml) {
	final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers");
	final String name = "packets";

	this.name = "Packets";
	this.enabled = configYml.getBoolean(name + ".enabled");
	this.cancelVls = configYml.getDouble(name + ".cancel_vls");
	this.reduceVls = configYml.getDouble(name + ".reduce_vls");
	this.offline = configYml.getBoolean(name + ".offline");
	this.dataVls = configYml.getDouble(name + ".data.vls");
	this.dataBytes = configYml.getInt(name + ".data.bytes", 24000);
	this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268);
	this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47);
	this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200);
	this.windowClick = configYml.getDouble(name + ".window_click");
	this.blockPlaceVls = configYml.getDouble(name + ".block_place");
	this.blockDigVls = configYml.getDouble(name + ".block_dig");
	this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot");
	this.violations = new Violations(configYml.getConfigurationSection(name + ".violations"));

	for (final String key : configurationSection.getKeys(false))
		multipliers.put(key, configurationSection.getDouble(key));
}
 
源代码2 项目: HeavySpleef   文件: InventoryEntryConfig.java
@Override
public final void inflateUnsafe(Configuration config, Object[] args) throws ParseException {
	ConfigurationSection layoutSection = config.getConfigurationSection("layout");
	String title;
	List<String> lore;
	
	if (layoutSection != null) {
		title = layoutSection.getString("title", DEFAULT_TITLE);
		lore = layoutSection.getStringList("lore");
		
		if (lore == null || lore.isEmpty()) {
			lore = DEFAULT_LORE;
		}
	} else {
		title = DEFAULT_TITLE;
		lore = DEFAULT_LORE;
	}
	
	layout = new InventoryEntryLayout(title, lore);
}
 
源代码3 项目: ExploitFixer   文件: ModuleManager.java
public void reload(final Configuration configYml, final Configuration messagesYml, final Configuration spigotYml) {
	try {
		this.commandsModule.reload(configYml);
		this.connectionModule.reload(configYml);
		this.customPayloadModule.reload(configYml);
		this.itemsFixModule.reload(configYml);
		this.messagesModule.reload(messagesYml);
		this.notificationsModule.reload(configYml);
		this.packetsModule.reload(configYml);
		this.exploitPlayerManager.reload();
	} catch (final NullPointerException e) {
		final Server server = plugin.getServer();

		server.getLogger().log(Level.SEVERE,
				"Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!");
		server.getPluginManager().disablePlugin(plugin);

		e.printStackTrace();
	}
}
 
源代码4 项目: ProjectAres   文件: MatchManager.java
/**
 * Creates a new map manager with a specified map rotation.
 */
@Inject MatchManager(Loggers loggers,
                     @Named("pluginData") Path pluginDataFolder,
                     Provider<Configuration> config,
                     MapLibrary mapLibrary,
                     MapLoader mapLoader,
                     MapErrorTracker mapErrorTracker,
                     FileRotationProviderFactory fileRotationProviderFactory,
                     EventBus eventBus,
                     MatchLoader matchLoader) throws MapNotFoundException {

    this.pluginDataFolder = pluginDataFolder;
    this.mapErrorTracker = mapErrorTracker;
    this.fileRotationProviderFactory = fileRotationProviderFactory;
    this.log = loggers.get(getClass());
    this.config = config;
    this.mapLibrary = mapLibrary;
    this.mapLoader = mapLoader;
    this.eventBus = eventBus;
    this.matchLoader = matchLoader;
}
 
源代码5 项目: ProjectAres   文件: QuotaConfig.java
@Inject QuotaConfig(Configuration root) {
    this.config = root.getConfigurationSection("match-quotas");
    if(config == null) {
        quotas = new TreeSet<>();
    } else {
        quotas = new TreeSet<>(Collections2.transform(
            config.getKeys(false),
            new Function<String, Entry>() {
                @Override
                public Entry apply(@Nullable String key) {
                    return new Entry(config.getConfigurationSection(key));
                }
            }
        ));
    }
}
 
源代码6 项目: ProjectAres   文件: FileRotationProviderFactory.java
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) {
    ConfigurationSection base = config.getConfigurationSection("rotation.providers.file");
    if(base == null) return Collections.emptySet();

    Set<RotationProviderInfo> providers = new HashSet<>();
    for(String name : base.getKeys(false)) {
        ConfigurationSection provider = base.getConfigurationSection(name);

        Path rotationFile = Paths.get(provider.getString("path"));
        if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile);

        int priority = provider.getInt("priority", 0);

        if(Files.isRegularFile(rotationFile)) {
            providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority));
        } else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) {
            // This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now
            mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile);
        }
    }

    return providers;
}
 
源代码7 项目: HeavySpleef   文件: BungeemodeAddon.java
private boolean checkCopyConfig() throws IOException {
	File file = new File(getDataFolder(), CONFIG_FILE_NAME);
	if (file.exists()) {
		Configuration config = YamlConfiguration.loadConfiguration(file);
		int version = config.getInt("config-version");
		
		if (version < BungeemodeConfig.CURRENT_CONFIG_VERSION) {
			Path dataFolderPath = getDataFolder().toPath();
			Files.move(file.toPath(), dataFolderPath.resolve("config_old.yml"), StandardCopyOption.REPLACE_EXISTING);
			return true;
		}
	} else {
		return true;
	}
	
	return false;
}
 
源代码8 项目: HeavySpleef   文件: HeavySpleef.java
private void checkConfigVersions(Configuration config, Path dataFolder) {
	if (config.getInt("config-version") < DefaultConfig.CURRENT_CONFIG_VERSION) {
		Path configSource = dataFolder.resolve(ConfigType.DEFAULT_CONFIG.getDestinationFileName());
		Path configTarget = dataFolder.resolve("config_old.yml");
		
		try {
			Files.move(configSource, configTarget, StandardCopyOption.REPLACE_EXISTING);
			URL configResource = getClass().getResource(ConfigType.DEFAULT_CONFIG.getClasspathResourceName());
			
			copyResource(configResource, configSource.toFile());
			
			ConsoleCommandSender sender = Bukkit.getConsoleSender();
			sender.sendMessage(ChatColor.RED + "Due to a HeavySpleef update your old configuration has been renamed");
			sender.sendMessage(ChatColor.RED + "to config_old.yml and a new one has been generated. Make sure to");
			sender.sendMessage(ChatColor.RED + "apply your old changes to the new config");
		} catch (IOException e) {
			getLogger().log(Level.SEVERE, "Could not create updated configuration due to an IOException", e);
		}
	}
}
 
源代码9 项目: HeavySpleef   文件: DatabaseConfig.java
@Override
public void inflate(Configuration config, Object... args) {
	Validate.isTrue(args.length > 0, "args.length must be greater than 0");
	Validate.isTrue(args[0] instanceof File, "args[0] must be an instance of " + File.class.getCanonicalName());
	
	File baseDir = (File) args[0];
	
	ConfigurationSection moduleSection = config.getConfigurationSection("database-modules");
	this.statisticsEnabled = moduleSection.getBoolean("statistics.enabled");
	this.maxStatisticCacheSize = moduleSection.getInt("statistics.max-cache-size", DEFAULT_MAX_CACHE_SIZE);
	
	this.connections = Lists.newArrayList();
	ConfigurationSection connectionsSection = config.getConfigurationSection("persistence-connection");
	
	for (String key : connectionsSection.getKeys(false)) {
		connections.add(new DatabaseConnection(connectionsSection.getConfigurationSection(key), baseDir));
	}
}
 
源代码10 项目: ExploitFixer   文件: ItemsFixModule.java
final public void reload(final Configuration configYml) {
	final String name = getName().toLowerCase();

	this.enabled = configYml.getBoolean(name + ".enabled", true);
	this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10);
	this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64);
	this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist"));
}
 
源代码11 项目: ExploitFixer   文件: ConnectionModule.java
public void reload(final Configuration configYml) {
	final YamlConfiguration configYml1 = (YamlConfiguration) configYml;

	this.uuidSpoofEnabled = configYml1.getBoolean("connection.uuidspoof");
	this.nullAddressEnabled = configYml1.getBoolean("connection.nulladdress");
	this.name = "UUID-Spoof";
	this.punishments = new HashSet<>(configYml1.getStringList("connection.punishments"));
}
 
源代码12 项目: ExploitFixer   文件: ModuleManager.java
public ModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) {
	this.plugin = plugin;
	this.commandsModule = new CommandsModule(configYml);
	this.connectionModule = new ConnectionModule(configYml);
	this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml);
	this.itemsFixModule = new ItemsFixModule(plugin, configYml);
	this.messagesModule = new MessagesModule(plugin.getDescription().getVersion(), messagesYml);
	this.notificationsModule = new NotificationsModule(plugin.getServer().getConsoleSender(), configYml);
	this.packetsModule = new PacketsModule(plugin, this, configYml);
	this.exploitPlayerManager = new ExploitPlayerManager(plugin, plugin.getServer(), this);
}
 
源代码13 项目: Kettle   文件: YamlConfiguration.java
@Override
protected String buildHeader() {
    String header = options().header();

    if (options().copyHeader()) {
        Configuration def = getDefaults();

        if ((def != null) && (def instanceof FileConfiguration)) {
            FileConfiguration filedefaults = (FileConfiguration) def;
            String defaultsHeader = filedefaults.buildHeader();

            if ((defaultsHeader != null) && (defaultsHeader.length() > 0)) {
                return defaultsHeader;
            }
        }
    }

    if (header == null) {
        return "";
    }

    StringBuilder builder = new StringBuilder();
    String[] lines = header.split("\r?\n", -1);
    boolean startedHeader = false;

    for (int i = lines.length - 1; i >= 0; i--) {
        builder.insert(0, "\n");

        if ((startedHeader) || (lines[i].length() != 0)) {
            builder.insert(0, lines[i]);
            builder.insert(0, COMMENT_PREFIX);
            startedHeader = true;
        }
    }

    return builder.toString();
}
 
源代码14 项目: ProjectAres   文件: Config.java
public static Configuration getConfiguration() {
    PGM pgm = PGM.get();
    if(pgm != null) {
        return pgm.getConfig();
    } else {
        return new YamlConfiguration();
    }
}
 
源代码15 项目: ProjectAres   文件: RotationManager.java
public RotationManager(Logger logger, Configuration config, PGMMap defaultMap, Collection<RotationProviderInfo> providers) {
    this.logger = ClassLogger.get(checkNotNull(logger, "logger"), getClass());
    this.config = config;
    this.providers = Collections.synchronizedSortedSet(Sets.newTreeSet(providers));

    load(defaultMap);
}
 
源代码16 项目: EliteMobs   文件: NPCEntity.java
/**
 * Spawns NPC based off of the values in the NPCConfig config file. Runs at startup and on reload.
 *
 * @param key Name of the config key for this NPC
 */
public NPCEntity(String key) {

    this.key = key;

    key += ".";

    Configuration configuration = ConfigValues.npcConfig;

    if (!setSpawnLocation(configuration.getString(key + NPCConfig.LOCATION))) return;
    if (!configuration.getBoolean(key + NPCConfig.ENABLED)) return;

    this.villager = (Villager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VILLAGER);

    this.villager.setRemoveWhenFarAway(true);

    setName(configuration.getString(key + NPCConfig.NAME));
    initializeRole(configuration.getString(key + NPCConfig.ROLE));
    setProfession(configuration.getString(key + NPCConfig.TYPE));
    setGreetings(configuration.getStringList(key + NPCConfig.GREETINGS));
    setDialog(configuration.getStringList(key + NPCConfig.DIALOG));
    setFarewell(configuration.getStringList(key + NPCConfig.FAREWELL));
    setCanMove(configuration.getBoolean(key + NPCConfig.CAN_MOVE));
    setCanTalk(configuration.getBoolean(key + NPCConfig.CAN_TALK));
    setActivationRadius(configuration.getDouble(key + NPCConfig.ACTIVATION_RADIUS));
    setDisappearsAtNight(configuration.getBoolean(key + NPCConfig.DISAPPEARS_AT_NIGHT));
    setNpcInteractionType(configuration.getString(key + NPCConfig.INTERACTION_TYPE));

    EntityTracker.registerNPCEntity(this);
    addNPCEntity(this);

}
 
源代码17 项目: EliteMobs   文件: DefaultConfig.java
public void loadConfiguration() {

        Configuration configuration = Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig();

        configuration.addDefault(SUPERMOB_STACK_AMOUNT, 50);
        configuration.addDefault(MMORPG_COLORS, true);
        configuration.addDefault(CREEPER_PASSIVE_DAMAGE_PREVENTER, true);
        configuration.addDefault(ENABLE_PERMISSION_TITLES, true);
        configuration.addDefault(ENABLE_POWER_SCOREBOARDS, false);
        configuration.addDefault(ALWAYS_SHOW_NAMETAGS, false);
        configuration.addDefault(HIDE_ENCHANTMENTS_ATTRIBUTE, false);
        configuration.addDefault(PREVENT_ITEM_PICKUP, true);
        configuration.addDefault(PREVENT_ELITE_MOB_CONVERSION_OF_NAMED_MOBS, true);
        configuration.addDefault(STRICT_SPAWNING_RULES, false);
        configuration.addDefault(PREVENT_MOUNT_EXPLOIT, true);
        configuration.addDefault(PREVENT_TOWER_EXPLOIT, true);
        configuration.addDefault(PREVENT_DARKROOM_EXPLOIT, true);
        configuration.addDefault(PREVENT_ENDERMAN_HEIGHT_EXPLOIT, true);
        configuration.addDefault(SKULL_SIGNATURE_ITEM, true);

        configuration.options().copyDefaults(true);

        UnusedNodeHandler.clearNodes(configuration);

        //save the config when changed
        Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).saveConfig();
        Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).saveDefaultConfig();

        Bukkit.getLogger().info("EliteMobs config loaded!");

    }
 
源代码18 项目: EliteMobs   文件: ConfigAssembler.java
public static void assemble(Configuration configuration, String path, String itemType, String itemName,
                            List<String> itemLore, List<String> enchantments,
                            List<String> potionEffects, String itemWeight, String itemScalability) {

    configuration.addDefault("Items." + path + ".Item Type", itemType);
    configuration.addDefault("Items." + path + ".Item Name", itemName);
    configuration.addDefault("Items." + path + ".Item Lore", itemLore);
    configuration.addDefault("Items." + path + ".Enchantments", enchantments);
    configuration.addDefault("Items." + path + ".Potion Effects", potionEffects);
    configuration.addDefault("Items." + path + ".Drop Weight", itemWeight);
    configuration.addDefault("Items." + path + ".Scalability", itemScalability);

}
 
源代码19 项目: Shopkeepers   文件: Settings.java
public static void loadLanguageConfiguration(Configuration config) {
	try {
		Field[] fields = Settings.class.getDeclaredFields();
		for (Field field : fields) {
			if (field.getType() == String.class && field.getName().startsWith("msg")) {
				String configKey = toConfigKey(field.getName());
				field.set(null, Utils.colorize(config.getString(configKey, (String) field.get(null))));
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
源代码20 项目: uSkyBlock   文件: LevelConfigYmlWriter.java
public YmlConfiguration writeToConfig(YmlConfiguration config, BlockLevelConfigMap map) {
    Configuration root = config.getRoot();
    ConfigurationSection blocks = root.createSection("blocks");
    BlockLevelConfig mapDefault = map.getDefault();
    map.values().stream()
            .distinct()
            .filter(f -> !isDefaultValues(f, mapDefault))
            .sorted(Comparator.comparing(BlockLevelConfig::getKey))
            .forEach(e -> writeToSection(blocks.createSection(createSectionKey(e)), e, mapDefault));
    return config;
}
 
源代码21 项目: HeavySpleef   文件: ThrowingConfigurationObject.java
@Override
public void inflate(Configuration config, Object... args) {
	try {
		inflateUnsafe(config, args);
	} catch (Exception e) {
		Class<? extends E> clazz = getExceptionClass();
		if (clazz.isInstance(e)) {
			throw new UnsafeException(e);
		} else if (e instanceof RuntimeException) {
			throw (RuntimeException) e;
		}
		
		//This part shouldn't be executed
	}
}
 
源代码22 项目: ExploitFixer   文件: CustomPayloadModule.java
public CustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) {
	reload(configYml);
}
 
源代码23 项目: HeavySpleef   文件: InventoryEntryConfig.java
public InventoryEntryConfig(Configuration config) {
	super(config);
}
 
源代码24 项目: ExploitFixer   文件: ItemsFixModule.java
public ItemsFixModule(final Plugin plugin, final Configuration configYml) {
	this.plugin = plugin;
	reload(configYml);
}
 
源代码25 项目: ExploitFixer   文件: ConnectionModule.java
public ConnectionModule(final Configuration configYml) {
	reload(configYml);
}
 
源代码26 项目: ExploitFixer   文件: CommandsModule.java
public CommandsModule(final Configuration configYml) {
	reload(configYml);
}
 
源代码27 项目: ExploitFixer   文件: MessagesModule.java
public MessagesModule(final String version, final Configuration messagesYml) {
	reload(messagesYml);
	this.version = version;
}
 
源代码28 项目: ExploitFixer   文件: MessagesModule.java
public void reload(final Configuration messagesYml) {
	this.messagesYml = messagesYml;
}
 
源代码29 项目: ExploitFixer   文件: PacketsModule.java
public PacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) {
	reload(configYml);
}
 
源代码30 项目: ExploitFixer   文件: NotificationsModule.java
public NotificationsModule(final CommandSender console, final Configuration configYml) {
	this.console = console;
	reload(configYml);
}
 
 类所在包
 同包方法