Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/4.1 #109

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Update/4.1 #109

wants to merge 28 commits into from

Conversation

cooffeeRequired
Copy link
Owner

@cooffeeRequired cooffeeRequired commented Nov 14, 2024

Pull Request: Major Update to skJson Project

Important

Breaking Changes
This update includes breaking changes that may impact existing implementations. Please review the changes carefully to adapt your code accordingly.

Summary of Changes

Added Files

  • ConfigurationSupport.java: Introduced new support functionality for managing configuration files effectively.

    // Example usage
    ConfigurationSupport config = new ConfigurationSupport("config.yml");
    config.load();
  • HttpModule.java: Added a new module to handle HTTP-related operations, providing extended capabilities for network communication.

    // Example usage
    HttpModule http = new HttpModule();
    http.sendGetRequest("https://example.com/api");
  • GsonParser.java: Implemented a new parser using GSON for better JSON serialization and deserialization.

    // Example usage
    GsonParser parser = new GsonParser();
    String json = parser.toJson(myObject);
    MyObject obj = parser.fromJson(json, MyObject.class);
  • PluginConfig.java: Added a new utility class for managing plugin configurations.

    // Example usage
    PluginConfig pluginConfig = new PluginConfig("plugin-settings.yml");
    pluginConfig.saveDefaults();
  • Register.java: Introduced a new API to streamline the registration process for various components.

    // Example usage
    Register register = new Register();
    register.addComponent(new MyComponent());

Removed Files

  • DeprecatedConfig.java: Removed outdated configuration support to make way for the new ConfigurationSupport.java.
  • OldHttpHandler.java: Removed the old HTTP handler in favor of the newly introduced HttpModule.java.

Modified Files

  • Main.java:

    • Refactored to use the new HttpModule and GsonParser for improved efficiency.
    • Removed dependencies on deprecated methods and updated logic accordingly.
    // Updated code snippet
    HttpModule http = new HttpModule();
    GsonParser parser = new GsonParser();
    String response = http.sendGetRequest("https://example.com/api");
    MyObject obj = parser.fromJson(response, MyObject.class);
  • Utils.java:

    • Minor updates for compatibility with the new configuration handling classes.
    // Example of updated utility method
    public static void updateConfig(ConfigurationSupport config) {
        config.set("key", "value");
        config.save();
    }

Breaking Changes

  • The removal of old configuration and HTTP handling classes will require users to migrate to the new ConfigurationSupport and HttpModule. These changes are not backward compatible, and any code that depended on the deprecated classes must be updated.

Why These Changes?

  • Improved Modularity: The new additions aim to make the codebase more modular, allowing for easier maintenance and extensibility.
  • Efficiency: The updated methods and classes are designed to enhance the performance of key operations, especially related to configuration management and JSON parsing.
  • Future-Proofing: Deprecated classes were removed to ensure the codebase stays up to date and avoids technical debt, simplifying future improvements.

Please ensure that your current projects are updated to be compatible with these changes. The changes were made with a focus on improving performance, modularity, and maintainability of the skJson project.

If you have any questions or run into issues while updating, please let us know!

…ynamically enable or disable different sub addons of SkJson as like cache, json itself, http handling or either nbt, also new Registering API allows handle the registration handle by global knowns patterns as LIKE SOLID, KISS, DRY, YAGNI, GRASP
               - Přidána podpora pro registraci více modulů pomocí @ExternalAPI anotace v třídě Register.java.
               - Přidáno několik tříd a metod pro integraci se Skript pluginem, včetně skriptovaných efektů, výrazů, událostí a funkcí.
               - Implementována metoda printAllRegistered pro výpis všech registrovaných elementů.
               - Přidán nový SkriptRegister pro zjednodušení registrace Skript elementů.
               - Přidáno zvýraznění v konzolových zprávách pomocí metody coloredElement.
               - V CustomLogger.java přidány getter metody pro konstanty a zlepšeno logování chyb a informací.
               - Rozšířena třída SkJson o novou instanci Configuration a přidání plánované aktualizace konfigurace při načítání pluginu.
	       - Přidána podpora pro registraci více modulů pomocí @ExternalAPI anotace v třídě Register.java.
               - Přidáno několik tříd a metod pro integraci se Skript pluginem, včetně skriptovaných efektů, výrazů, událostí a funkcí.
               - Implementována metoda printAllRegistered pro výpis všech registrovaných elementů.
               - Přidán nový SkriptRegister pro zjednodušení registrace Skript elementů.
               - Přidáno zvýraznění v konzolových zprávách pomocí metody coloredElement.
               - V CustomLogger.java přidány getter metody pro konstanty a zlepšeno logování chyb a informací.
               - Rozšířena třída SkJson o novou instanci Configuration a přidání plánované aktualizace konfigurace při načítání pluginu.

   - Added support for registering multiple modules using the
     @ExternalAPI annotation in the Register.java class.
        - Added several classes and methods for integration with the
	  Skript plugin, including scripted effects, expressions,
	  events, and functions.
	     - Implemented the printAllRegistered method to list all
	       registered elements.
	          - Added a new SkriptRegister for simplifying the
		    registration of Skript elements.
		       - Added highlighting in console messages using
			 the coloredElement method.
			    - Added getter methods for constants in
			      CustomLogger.java and improved error and
			      information logging.
			         - Extended the SkJson class with a new
				   Configuration instance and added
				   scheduled configuration update during
				   plugin loading.
   - Added support for registering multiple modules using the @ExternalAPI annotation in the Register.java class.
   - Added several classes and methods for integration with the Skript plugin, including scripted effects, expressions, events, and functions.
   - Implemented the printAllRegistered method to list all registered elements.
   - Added a new SkriptRegister for simplifying the registration of Skript elements.
   - Added highlighting in console messages using the coloredElement method.
   - Added getter methods for constants in CustomLogger.java and improved error and information logging.
   - Extended the SkJson class with a new Configuration instance and added scheduled configuration update during plugin loading.
…ions

               - Added BukkitSerializableAdapter class, which implements JsonSerializer and JsonDeserializer for objects implementing the ConfigurationSerializable interface.
               - Modified the Register class:
                 - Added the 
egisterModules method to allow registering new modules annotated with Module.
                 - Reorganized some methods for better readability and code structure.
               - Updated the CustomLogger class:
                 - Added the colorize method for formatting text with colors.
                 - Filtered unnecessary logs for better console clarity.
               - Added the GsonParser class to facilitate working with objects to be serialized into JSON format using Gson.

               This change improves interoperability with Bukkit configurations and optimizes logging for more efficient debugging.
               ## Enhancements
               1. **New Class Added**: JsonCache.java
                   - A generic caching class for asynchronous handling of JSON elements.
                   - Uses ConcurrentHashMap and CompletableFuture for efficient operations.

               2. **New Class Added**: JsonFileWatcher.java
                   - Monitors directories for JSON file changes.
                   - Utilizes WatchService for detecting file modifications.
                   - Schedules tasks with ScheduledExecutorService.

               3. **Modified Class**: SkJson.java
                   - Integrated JsonFileWatcher for logging watcher status.
                   - Cleaned up by removing unnecessary JSON serialization/deserialization code.
                   - Removed unused imports and test cases.

               ## Code Cleanup
               - Deprecated JSON parsing experiments and legacy test cases have been removed.
               - Unused imports and random game world object test cases were eliminated for better clarity and maintainability.
               ## 1. Modifications in CustomLogger

               - Changed the method colorize from static to instance.

               `java
               public Component colorize(String text) {
                   return converter.deserialize(text);
               }
               `

               ## 2. Updates in SkJson Class

               - Imported new classes for commands, item management, and JSON parsing.
               - Added a new command about to display plugin information.
## 1. Modifications in `CustomLogger`

- Changed the method `colorize` from static to instance.

```java
public Component colorize(String text) {
    return converter.deserialize(text);
}
```

## 2. Updates in `SkJson` Class

- Imported new classes for commands, item management, and JSON parsing.
- Added a new command `"about"` to display plugin information.
- Created enchanted items (sword, golden apple, enchanted book) with custom metadata and NBT data.
- Serialized the created items to JSON and logged them.
- Deserialized the JSON back to item objects and logged them.

## 3. Added `GenericFlatObjectAdapter` Class

- Implemented a custom JSON serializer and deserializer for handling generic flat objects.

## 4. Updates in `GsonParser`

- Registered the new `GenericFlatObjectAdapter` in the `Gson` instance.

```java
@Getter final static Gson gson = new GsonBuilder()
    .serializeNulls()
    .enableComplexMapKeySerialization()
    .registerTypeAdapter(ItemStack.class, new NBTFallBackItemStackAdapter())
    .registerTypeHierarchyAdapter(ConfigurationSerializable.class, new BukkitSerializableAdapter())
    .registerTypeHierarchyAdapter(Object.class, new GenericFlatObjectAdapter<>())
    .setPrettyPrinting()
    .create();
```

## 5. Changes in `dependencies.gradle`

- Added a new dependency for `snakeyaml`.

```groovy
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.3'
```
…le an async operations, also add FileHandler, what contains functions for handle all IO operations for json and yaml files
@cooffeeRequired cooffeeRequired linked an issue Nov 18, 2024 that may be closed by this pull request
cooffeeRequired and others added 4 commits November 18, 2024 18:20
>[!NOTE]
>This commit includes the following changes:

## Added
- New class `cz.coffeerequired.api.http.RequestResponse$1`
  - Added for managing HTTP response specifics in the API.

- New class `cz.coffeerequired.api.http.RequestClient`
  - Introduced for handling HTTP client requests within the API.

- New class `cz.coffeerequired.support.Support`
  - Created to provide additional support utilities for the project.

- New class `cz.coffeerequired.SkJson`
  - The main class for the SkJson plugin, integrating new features and configurations.

- New class `cz.coffeerequired.skript.json.ExprNewJson`
  - Implemented to handle new JSON expressions in Skript.

- New class `cz.coffeerequired.api.Commands`
  - Added for managing plugin commands more effectively.

- New class `cz.coffeerequired.api.annotators.ExternalAPI`
  - Included to handle annotations for external APIs.

- New class `cz.coffeerequired.api.http.RequestHeaders`
  - Added for managing HTTP request headers.

- New class `cz.coffeerequired.api.json.bukkit.EventFileWatcher`
  - Introduced to watch and handle event files for Bukkit.

- New class `cz.coffeerequired.api.json.BukkitSerializableAdapter`
  - Added for serializing and deserializing JSON objects in Bukkit.

- New class `cz.coffeerequired.skript.json.EffMapJson`
  - Implemented to process JSON mappings in Skript.
- remover, changer, setter, getter, counter
…er, counter (#111)

**SerializedJson**
- searcher
- - searcher.get() ✅ [Objects]
- counter
- - counter.keys() ✅ [Objects]
- - counter.values() ✅ [Arrays,Objects]
- changer
- - changer.key() ✅ [Objects]
- - changer.values() ✅ [Arrays,Objects]
- remover
- - remover.byValue() ✅ [Arrays,Objects]
- - remover.byIndex()✅[Arrays]
- - remover.byKey() ✅[Objects]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant