• Es freut uns dass du in unser Minecraft Forum gefunden hast. Hier kannst du mit über 130.000 Minecraft Fans über Minecraft diskutieren, Fragen stellen und anderen helfen. In diesem Minecraft Forum kannst du auch nach Teammitgliedern, Administratoren, Moderatoren , Supporter oder Sponsoren suchen. Gerne kannst du im Offtopic Bereich unseres Minecraft Forums auch über nicht Minecraft spezifische Themen reden. Wir hoffen dir gefällt es in unserem Minecraft Forum!
  • Haftungsausschluss! Diese Ressource stammt nicht von uns, sondern von dem jeweiligen Autor. Leider können wir nicht alle Downloads prüfen, weswegen wir, minecraft-server.eu, uns von diesen klar distanzieren müssen. Bitte wende dich bei Fehlern, Störungen oder gar Betrug der durch diesen Download verursacht wurde direkt an den Autor. Gerne kannst du uns informieren, damit wir u. U. entsprechende Downloads sperren können.
Resource icon

Bukkit ConfigLib v4.2.0

Lizenz
MIT license
Source Code
https://github.com/Exlll/ConfigLib
Tired of Bukkit's configuration system? Use this library instead! Just write Java code and let this library do the rest. More information on GitHub.

This library facilitates creating, saving, loading, updating, and commenting YAML configuration files. It does so by automatically mapping instances of configuration classes to serializable maps which are first transformed into YAML and then saved to some specified file.

For a step-by-step tutorial that shows most features of this library in action check out the Tutorial page on the wiki!

This library is also available as a BungeeCord (/ Waterfall) plugin.

Features
  • Automatic creation, saving, loading, and updating of configuration files
  • Support for comments through annotations
  • Support for all primitive types, their wrapper types, and strings
  • Support for enums, records, and POJOs (+ inheritance!)
  • Support for (nested) lists, sets, arrays, and maps
  • Support for BigInteger and BigDecimal
  • Support for LocalDate, LocalTime, LocalDateTime, and Instant
  • Support for UUID, File, Path, URL, and URI
  • Support for Bukkit's ConfigurationSerializable types (e.g. ItemStack)
  • Option to exclude fields from being converted
  • Option to format field and component names before conversion
  • Option to customize null handling
  • Option to customize serialization by providing your own serializers
  • Option to add headers and footers to configuration files
  • ...and a few more!
Example:

This section contains a short usage example to get you started. The whole range of features is discussed on GitHub. Information on how to import this library is also located there.

For a step-by-step tutorial with a more advanced example check out the Tutorial page on the wiki.

If you want support Bukkit classes like ItemStack, check out the Configuration properties section on GitHub.

Java:
public final class Example {
    // * To create a configuration annotate a class with @Configuration and make sure that
    //   it has a no-args constructor.
    // * Now add fields to that class and assign them default values.
    // * That's it! Fields can be private; setters are not required.
    @Configuration
    public static class BaseConfiguration {
        private String host = "127.0.0.1";
        private int port = 1234;
        // The library supports lists, sets, and maps.
        private Set<String> blockedAddresses = Set.of("8.8.8.8");
        // Fields can be ignored by making them final, transient, static or by
        // annotating them with @Ignore.
        private final double ignoreMe = 3.14;
    }

    // This library supports records; no @Configuration annotation required
    public record User(
            String username,
            @Comment("Please choose a strong password.")
            String password
    ) {}

    // Subclassing of configurations and nesting of configurations in other configurations
    // is also supported. Subclasses don't need to be annotated again.
    public static final class UserConfiguration extends BaseConfiguration {
        // You can add comments with the @Comment annotation. Each string in the comment
        // array is written (as a comment) on a new line.
        @Comment({"The admin user has full access.", "Choose a proper password!"})
        User admin = new User("root", "toor"); // The User class is a record!
        List<User> blockedUsers = List.of(
                new User("user1", null), // null values are supported
                new User("user2", null)
        );
    }

    public static void main(String[] args) {
        var configFile = Paths.get("/tmp/config.yml");
        var config = new UserConfiguration();

        // Save a new instance to the configuration file
        YamlConfigurations.save(configFile, UserConfiguration.class, config);

        // Load a new instance from the configuration file
        config = YamlConfigurations.load(configFile, UserConfiguration.class);
        System.out.println(config.admin.username);
        System.out.println(config.blockedUsers);

        // Modify and save the configuration file
        config.blockedUsers.add(new User("user3", "pass3"));
        YamlConfigurations.save(configFile, UserConfiguration.class, config);
    }
}

Executing the code above creates the following configuration file:
YAML:
host: 127.0.0.1
port: 1234
blockedAddresses:
  - 8.8.8.8
# The admin user has full access.
# Choose a proper password!
admin:
  username: root
  # Please choose a strong password.
  password: toor
blockedUsers:
  - username: user1
  - username: user2
  - username: user3
     password: pass3

For a detailed description of the capabilities and a documentation of this library, check out the repository on GitHub!
Autor
Exlll
Downloads
86
Aufrufe
389
Erste Veröffentlichung
Letzte Aktualisierung
Bewertung
0,00 Stern(e) 0 Bewertung(en)

Letzte Updates

  1. ConfigLib version 4.2.0

    Support for polymorphic serialization This release adds the Polymorphic and PolymorphicTypes...
  2. ConfigLib version 4.0.0

    This update contains several new features: Support for Java records Support for File, Path...
Oben