Skip to content

Commit

Permalink
🐺🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarokIce committed Dec 24, 2024
2 parents 053b2bc + 9b8608e commit 46203a1
Show file tree
Hide file tree
Showing 31 changed files with 452 additions and 72 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ jobs:
matrix:
java:
- 21
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: "microsoft"
- name: setup gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
run: ./gradlew build --warning-mode=all
- name: capture build artifacts
if: ${{ matrix.java == '21' }}
uses: actions/upload-artifact@v4
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/greetings.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/spotless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run spotless
on: [push, workflow_dispatch]

permissions:
contents: write

jobs:
build:
strategy:
matrix:
java:
- 21
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: "microsoft"
- name: setup gradle
uses: gradle/actions/setup-gradle@v4
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: apply spotless
run: ./gradlew spotlessApply
- name: commit changes and push
uses: EndBug/add-and-commit@v9
with:
message: "chore: Apply Spotless"
default_author: github_actions
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,26 @@
*/
package band.kessoku.lib.api.base;

import java.lang.reflect.Constructor;
import java.util.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.jetbrains.annotations.NotNull;

public final class KessokuUtils {
private KessokuUtils() {
}

public static <T> boolean isType(final List<?> list, final Class<T> type) {
for (final Object element : list) {
public static <T> boolean isType(final Collection<?> collection, final Class<T> type) {
for (final Object element : collection) {
if (!(type.isInstance(element))) {
return false;
}
}
return true;
}

public static <V> V constructUnsafely(final Class<V> cls) {
try {
final Constructor<V> constructor = cls.getDeclaredConstructor();
constructor.setAccessible(true);
return constructor.newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}

public static <K, V> @NotNull Set<K> getKeysByValue(final Map<K, V> map, final V value) {
final Set<K> result = new HashSet<>();
map.forEach((k, v) -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2024 KessokuTeaTime
*
* Licensed under the GNU Lesser General Pubic License, Version 3 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/lgpl-3.0.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package band.kessoku.lib.api.base.reflect;

import java.lang.reflect.Member;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2024 KessokuTeaTime
*
* Licensed under the GNU Lesser General Pubic License, Version 3 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/lgpl-3.0.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package band.kessoku.lib.api.base.reflect;

import band.kessoku.lib.api.KessokuLib;
Expand All @@ -10,8 +25,13 @@ public final class ReflectUtil {
private ReflectUtil() {
}

public static boolean isAssignableFrom(Field field, Class<?>... clazzs) {
var flag = Arrays.stream(clazzs).anyMatch(clazz -> !field.getType().isAssignableFrom(clazz));
public static boolean isAssignableFrom(Field field, Class<?>... classes) {
var flag = Arrays.stream(classes).anyMatch(clazz -> !field.getType().isAssignableFrom(clazz));
return !flag;
}

public static boolean isAssignableFrom(Object o, Class<?>... classes) {
var flag = Arrays.stream(classes).anyMatch(clazz -> !o.getClass().isAssignableFrom(clazz));
return !flag;
}

Expand Down
12 changes: 12 additions & 0 deletions blockentity/common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apply from: rootProject.file("gradle/scripts/klib-common.gradle")

base.archivesName = rootProject.name + "-blockentity"

kessoku {
module("base", "common")
module("platform", "common")
}

dependencies {
implementation libs.aj4j
}
Binary file added blockentity/common/src/main/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions blockentity/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")

base.archivesName = rootProject.name + "-blockentity"

kessoku {
module("base", "common")

common("blockentity", ModPlatform.FABRIC)
shadowBundle("blockentity", ModPlatform.FABRIC)
}

dependencies {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 KessokuTeaTime
*
* Licensed under the GNU Lesser General Pubic License, Version 3 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/lgpl-3.0.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package band.kessoku.lib.impl.blockentity.fabric;

import net.fabricmc.api.ModInitializer;

public class KessokuBlockEntityFabric implements ModInitializer {
@Override
public void onInitialize() {

}
}
36 changes: 36 additions & 0 deletions blockentity/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"schemaVersion": 1,
"id": "kessoku_blockentity",
"version": "${version}",
"name": "Kessoku Block Entity",
"description": "Common blockentity API.",
"authors": [
"Kessoku Tea Time"
],
"contact": {
"homepage": "https://modrinth.com/mod/kessoku-lib",
"sources": "https://github.com/KessokuTeaTime/KessokuLib",
"issues": "https://github.com/KessokuTeaTime/KessokuLib/issues"
},
"license": "LGPL-3.0-only",
"icon": "icon.png",
"entrypoints": {
"main": [
"band.kessoku.lib.impl.blockentity.fabric.KessokuBlockEntityFabric"
]
},
"environment": "*",
"depends": {
"fabricloader": ">=0.16.0",
"minecraft": "1.21",
"java": ">=21",
"fabric-api": "*"
},
"custom": {
"modmenu": {
"badges": [
"library"
]
}
}
}
12 changes: 12 additions & 0 deletions blockentity/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

base.archivesName = rootProject.name + "-entrypoint"

kessoku {
module("base", "common")

common("blockentity", ModPlatform.NEOFORGE)
shadowBundle("blockentity", ModPlatform.NEOFORGE)
}
1 change: 1 addition & 0 deletions blockentity/neo/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge
29 changes: 29 additions & 0 deletions blockentity/neo/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
modLoader = "javafml"
loaderVersion = "[4,)"
license = "LGPL-3.0-only"
issueTrackerURL = "https://github.com/KessokuTeaTime/KessokuLib/issues"

[[mods]]
modId = "kessoku_blockentity"
version = "${version}"
displayName = "Kessoku Block Entity"
description = '''
Common blockentity API.
'''
logoFile = "icon.png"
authors = "Kessoku Tea Time"
displayURL = "https://modrinth.com/mod/kessoku-lib"

[[dependencies.kessoku_blockentity]]
modId = "neoforge"
type = "required"
versionRange = "[21.0,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.kessoku_blockentity]]
modId = "minecraft"
type = "required"
versionRange = "[1.21,)"
ordering = "NONE"
side = "BOTH"
6 changes: 3 additions & 3 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ plugins {

repositories {
mavenCentral()
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://maven.neoforged.net/releases/" }
maven { url = "https://maven.fabricmc.net/" }
maven { url = "https://maven.architectury.dev/" }
maven { url = "https://maven.neoforged.net/releases/" }
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class KessokuExtension {
protected static final List<String> MODULES = List.of(
"base",
"command",
"config",
//"config",
"data",
"entity-events",
"entrypoint",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 KessokuTeaTime
*
* Licensed under the GNU Lesser General Pubic License, Version 3 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/lgpl-3.0.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package band.kessoku.lib.api.config;

import band.kessoku.lib.impl.config.AbstractConfig;

public class Config extends AbstractConfig {
}
Loading

0 comments on commit 46203a1

Please sign in to comment.