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

4.5 long term changes #119

Merged
merged 47 commits into from
Jan 25, 2025
Merged

4.5 long term changes #119

merged 47 commits into from
Jan 25, 2025

Conversation

cooffeeRequired
Copy link
Owner

No description provided.

cooffeeRequired and others added 30 commits November 13, 2024 03:40
…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
>[!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]
- remover, changer, setter, getter, counter
               feat: add support for full json type
               feat: add support for new changer
               feat: add support for literal syntax
               feat: add support for watchers
@cooffeeRequired cooffeeRequired linked an issue Jan 25, 2025 that may be closed by this pull request
@cooffeeRequired cooffeeRequired merged commit 4b52f41 into main Jan 25, 2025
6 of 10 checks passed
@cooffeeRequired cooffeeRequired deleted the 4.5---Long-term-changes branch January 25, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refractor SkJson 4.5 - Long term changes
1 participant