Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .idea/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 81 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,100 @@
<div align="center">

<img width="4320" height="1080" alt="bits_logo" src="https://github.com/user-attachments/assets/fb7e3cc4-1533-40a9-b240-d2be153ea551" />
<p align="center"><b> 💾 A Utility library for Orbitary development.</b></p>

# Bits

*- Utility library for Orbitary development -*

[![License](https://img.shields.io/github/license/Orbitary/Bits)](LICENSE)
[![Java CI](https://github.com/Orbitary/Bits/actions/workflows/publish.yml/badge.svg)](https://github.com/Orbitary/Bits/actions/workflows/publish.yml)
[![Modrinth Downloads](https://img.shields.io/badge/dynamic/json?color=1bd96a&label=Modrinth&query=downloads&suffix=%20downloads&url=https%3A%2F%2Fapi.modrinth.com%2Fv2%2Fproject%2F8ZZ61TMj)](https://modrinth.com/mod/orbits)
[![](https://img.shields.io/github/license/Orbitary/Bits?style=flat-square)](LICENSE)
[![](https://img.shields.io/github/actions/workflow/status/Orbitary/Bits/publish.yml?style=flat-square)](https://github.com/Orbitary/Bits/actions/workflows/publish.yml)
[![](https://img.shields.io/badge/dynamic/json?color=1bd96a&label=modrinth&style=flat-square&query=downloads&suffix=%20downloads&url=https%3A%2F%2Fapi.modrinth.com%2Fv2%2Fproject%2F8ZZ61TMj)](https://modrinth.com/mod/orbits)

## About
</div>

Bits is a multi-platform utility library designed to streamline:
* * *

- Minecraft plugin development across Paper and Velocity platforms.
- Minecraft mod development using Fabric (both client and server).
- Discord Bot Development
- And more!
# ✨ Introduction

### Features:
**Bits** is a multi-platform utility library designed to streamline Minecraft plugin and mod development, as well as Discord bot development.

- Multi-platform support
- Annotation-based [Brigadier](https://github.com/Mojang/brigadier) Command API
- Sendable lifecycle builders (Actionbars, Sidebars, Waypoints, +)
- Automatic Text formatting
- Common Plugin utilities (Color, Sound, Location, Item, Math, Permission APIs)
- Built for **Paper**, **Velocity**, and **Fabric** (client & server).
- Annotation-based [Brigadier](https://github.com/Mojang/brigadier) **Command API**.
- **Sendable lifecycle builders** — Actionbars, Sidebars, Waypoints, and more.
- **Automatic text formatting** and common plugin utilities.
- Color, Sound, Location, Item, Math, and Permission APIs included.

> [!NOTE]
> This project is in active development, expect regular changes and additions!
> This project is in active development — expect regular changes and additions!

## 🛠️ Build info

## Installation
#### Modules

### Gradle (Kotlin DSL)
- **api** — Core interfaces and abstractions
- **paper** — Paper platform implementation
- **paper:sendable** — Actionbars, Sidebars, Waypoints
- **paper:command** — Brigadier command framework
- **velocity** — Velocity platform implementation
- **velocity:command** — Brigadier command framework
- **fabric** — Fabric platform implementation (client + server)

## 💻 API

<details open>
<summary>Gradle (Kotlin)</summary>

```kotlin
repositories {
maven { url = uri("https://repo.bitsquidd.xyz/repository/bit/") }
maven("https://repo.bitsquidd.xyz/repository/bit/")
}

dependencies {
// Core API
implementation("xyz.bitsquidd.bits:api:0.0.19")

// Platform implementation
implementation("xyz.bitsquidd.bits.paper:paper:0.0.19")
implementation("xyz.bitsquidd.bits.velocity:velocity:0.0.19")
implementation("xyz.bitsquidd.bits.fabric:fabric:0.0.19")
// Core API (required)
implementation("xyz.bitsquidd.bits:api:0.0.20")

// Platform implementations
implementation("xyz.bitsquidd.bits.paper:paper:0.0.20")
implementation("xyz.bitsquidd.bits.velocity:velocity:0.0.20")
implementation("xyz.bitsquidd.bits.fabric:fabric:0.0.20")

// Optional: Platform-specific modules
implementation("xyz.bitsquidd.bits.paper:sendable:0.0.19")
implementation("xyz.bitsquidd.bits.paper:command:0.0.19")
implementation("xyz.bitsquidd.bits.velocity:command:0.0.19")
implementation("xyz.bitsquidd.bits.paper:sendable:0.0.20")
implementation("xyz.bitsquidd.bits.paper:command:0.0.20")
implementation("xyz.bitsquidd.bits.velocity:command:0.0.20")
}
```

### Maven
</details>

<details>
<summary>Gradle (Groovy)</summary>

```groovy
repositories {
maven { url 'https://repo.bitsquidd.xyz/repository/bit/' }
}

dependencies {
// Core API (required)
implementation 'xyz.bitsquidd.bits:api:0.0.20'

// Platform implementations
implementation 'xyz.bitsquidd.bits.paper:paper:0.0.20'
implementation 'xyz.bitsquidd.bits.velocity:velocity:0.0.20'
implementation 'xyz.bitsquidd.bits.fabric:fabric:0.0.20'

// Optional: Platform-specific modules
implementation 'xyz.bitsquidd.bits.paper:sendable:0.0.20'
implementation 'xyz.bitsquidd.bits.paper:command:0.0.20'
implementation 'xyz.bitsquidd.bits.velocity:command:0.0.20'
}
```

</details>

<details>
<summary>Maven</summary>

```xml

Expand All @@ -67,36 +110,29 @@ dependencies {
<dependency>
<groupId>xyz.bitsquidd.bits</groupId>
<artifactId>api</artifactId>
<version>0.0.19</version>
<version>0.0.20</version>
</dependency>

<!-- Platform implementation (optional) -->
<!-- Platform implementations -->
<dependency>
<groupId>xyz.bitsquidd.bits.paper</groupId>
<artifactId>paper</artifactId>
<version>0.0.19</version>
<version>0.0.20</version>
</dependency>
<dependency>
<groupId>xyz.bitsquidd.bits.velocity</groupId>
<artifactId>velocity</artifactId>
<version>0.0.19</version>
<version>0.0.20</version>
</dependency>
<dependency>
<groupId>xyz.bitsquidd.bits.fabric</groupId>
<artifactId>fabric</artifactId>
<version>0.0.19</version>
<version>0.0.20</version>
</dependency>
</dependencies>
```

## Libraries

- **API** - Core interfaces and abstractions
- **Paper** - Paper platform implementation
- **Velocity** - Velocity platform implementation
- **Fabric** - Fabric platform implementation
- **Client** - Fabric client implementation
- **Server** - Fabric server implementation
</details>

---
Made with 🦑 by [ImBit](https://github.com/ImBit)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
package xyz.bitsquidd.bits.util.serializer;


import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.KeyDeserializer;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
Expand All @@ -23,27 +27,30 @@
import java.util.Set;
import java.util.stream.Collectors;


public final class SerializationManager {
private SerializationManager() {}

public static final ObjectMapper SERIALIZER = createMapper();

private static ObjectMapper createMapper() {
JsonMapper.Builder builder = JsonMapper.builder()
.enable(MapperFeature.DEFAULT_VIEW_INCLUSION)
.enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES)
.disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
.annotationIntrospector(new NullableAwareIntrospector());

getSerializers().forEach(serializer -> registerSerializer(serializer, builder));
builder.addModule(new GuavaModule());
builder.addModule(new JavaTimeModule());
return builder.build();
ObjectMapper mapper = new ObjectMapper();
mapper.enable(MapperFeature.DEFAULT_VIEW_INCLUSION);
mapper.enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES);
mapper.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
mapper.setDefaultPropertyInclusion(JsonInclude.Value.ALL_NON_NULL);
mapper.setAnnotationIntrospector(new NullableAwareIntrospector());

getSerializers().forEach(serializer -> registerSerializer(serializer, mapper));

mapper.registerModule(new GuavaModule());
mapper.registerModule(new JavaTimeModule());
return mapper;
}

private static <T> void registerSerializer(MultiSerializer<T> serializer, JsonMapper.Builder builder) {
private static <T> void registerSerializer(MultiSerializer<T> serializer, ObjectMapper mapper) {
SimpleModule module = new SimpleModule();
Class<T> targetClass = serializer.getTargetClass();
module.addSerializer(targetClass, serializer.jacksonSerializer());
Expand All @@ -54,7 +61,7 @@ private static <T> void registerSerializer(MultiSerializer<T> serializer, JsonMa
KeyDeserializer keyDeserializer = serializer.jacksonKeyDeserializer();
if (keyDeserializer != null) module.addKeyDeserializer(targetClass, keyDeserializer);

builder.addModule(module);
mapper.registerModule(module);
}

@SuppressWarnings("unchecked")
Expand Down
9 changes: 9 additions & 0 deletions api/src/main/java/xyz/bitsquidd/bits/util/wrapper/Enums.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ public static <E extends Enum<E>> String toIdentifier(E constant) {
}


/**
* Resolves an enum constant by a string identifier derived from the constant, ignoring case sensitivity.
*
* @since 0.0.20
*/
public static <E extends Enum<E>> Optional<E> getFromIdentifier(Class<E> enumClass, String identifier) {
return getFromIdentifier(enumClass, constant -> toIdentifier(constant).equals(identifier));
}

/**
* Searches for an enum constant that matches a specific predicate.
*
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
adventure = "4.26.1"
adventure = "5.1.1"
jackson = "2.21.4"

[libraries]
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion minecraft/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repositories {
dependencies {
group = "xyz.bitsquidd.bits.fabric"

minecraft("com.mojang:minecraft:26.1.2")
minecraft("com.mojang:minecraft:26.2")

shade(project(":minecraft"), transitive = true)
shade(project(":minecraft:module:command"), transitive = true)
Expand Down
6 changes: 3 additions & 3 deletions minecraft/fabric/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[libraries]
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.19.1" }
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.145.4+26.1.2" }
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.19.3" }
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.152.2+26.2" }

[plugins]
fabric-loom = { id = "net.fabricmc.fabric-loom", version = "1.16-SNAPSHOT" }
fabric-loom = { id = "net.fabricmc.fabric-loom", version = "1.17-SNAPSHOT" }
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
import net.fabricmc.loader.api.FabricLoader;

import xyz.bitsquidd.bits.mc.command.argument.BitsArgumentRegistry;
import xyz.bitsquidd.bits.mc.command.argument.parser.AbstractArgumentParser;
import xyz.bitsquidd.bits.mc.command.argument.parser.ArgumentParser;
import xyz.bitsquidd.bits.mc.command.provider.BitsCommandProvider;
import xyz.bitsquidd.bits.wrapper.collection.AddableSet;

import static xyz.bitsquidd.bits.mc.command.FabricBitsCommandManager.COMMAND_INSTANCE_ENTRYPOINT;


public class FabricClientBitsArgumentRegistry extends BitsArgumentRegistry<FabricClientCommandSource> {

/**
* Fabric mods must use the {@code COMMAND_INSTANCE_ENTRYPOINT} entrypoint to provide command parsers.
*/
@Override
protected AddableSet<AbstractArgumentParser<?>> initialiseParsers() {
protected AddableSet<ArgumentParser<?, ?>> initialiseParsers() {
return super.initialiseParsers().addAll(FabricLoader.getInstance()
.getEntrypoints(COMMAND_INSTANCE_ENTRYPOINT, BitsCommandProvider.class)
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
package xyz.bitsquidd.bits.mc.command.provider;

import xyz.bitsquidd.bits.mc.command.BitsCommand;
import xyz.bitsquidd.bits.mc.command.argument.parser.AbstractArgumentParser;
import xyz.bitsquidd.bits.mc.command.argument.parser.ArgumentParser;
import xyz.bitsquidd.bits.wrapper.collection.AddableSet;


public interface BitsCommandProvider {
default AddableSet<BitsCommand> getCommands() {
return AddableSet.empty();
}

default AddableSet<AbstractArgumentParser<?>> getArguments() {
default AddableSet<ArgumentParser<?, ?>> getArguments() {
return AddableSet.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import xyz.bitsquidd.bits.Bits;
import xyz.bitsquidd.bits.log.Logger;
import xyz.bitsquidd.bits.mc.command.argument.BrigadierArgumentMapping;
import xyz.bitsquidd.bits.mc.command.argument.parser.AbstractArgumentParser;
import xyz.bitsquidd.bits.mc.command.argument.parser.ArgumentParser;
import xyz.bitsquidd.bits.mc.command.debugging.TreeDebugger;
import xyz.bitsquidd.bits.mc.command.exception.CommandBuildException;
import xyz.bitsquidd.bits.mc.command.util.BitsCommandBuilder;
Expand Down Expand Up @@ -221,7 +221,7 @@ private Command<T> createCommandExecution(
ArrayList<@Nullable Object> parsedArguments = new ArrayList<>();

for (CommandParameterInfo parameter : methodInfo.getAllParameters()) {
AbstractArgumentParser<?> parser = parameter.getParser();
ArgumentParser<?, ?> parser = parameter.getParser();

// Collect primitive objects for the parameter
ArrayList<@Nullable Object> primitiveObjects = new ArrayList<>();
Expand Down
Loading
Loading