mirror of
https://github.com/HMCore/Core.git
synced 2025-12-12 13:56:19 +00:00
merged old changes
This commit is contained in:
39
.all-contributorsrc
Normal file
39
.all-contributorsrc
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"files": [
|
||||
"README.md"
|
||||
],
|
||||
"imageSize": 100,
|
||||
"commit": false,
|
||||
"contributors": [
|
||||
{
|
||||
"login": "wulkanat",
|
||||
"name": "Wieland Schöbl",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/19289296?v=4",
|
||||
"profile": "https://github.com/wulkanat",
|
||||
"contributions": [
|
||||
"test",
|
||||
"code",
|
||||
"doc",
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "UnrealValentin",
|
||||
"name": "UnrealValentin",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/30842467?v=4",
|
||||
"profile": "https://github.com/UnrealValentin",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"test",
|
||||
"code",
|
||||
"ideas"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
"projectName": "Core",
|
||||
"projectOwner": "HMCore",
|
||||
"repoType": "github",
|
||||
"repoHost": "https://github.com",
|
||||
"skipCi": true
|
||||
}
|
||||
24
README.md
24
README.md
@@ -1,4 +1,28 @@
|
||||
# Core
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
[](#contributors-)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
## The Core Mod of HMCore which powers the whole system.
|
||||
|
||||
### TODO
|
||||
|
||||
## Contributors ✨
|
||||
|
||||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||
<!-- prettier-ignore-start -->
|
||||
<!-- markdownlint-disable -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/wulkanat"><img src="https://avatars.githubusercontent.com/u/19289296?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wieland Schöbl</b></sub></a><br /><a href="https://github.com/HMCore/Core/commits?author=wulkanat" title="Tests">⚠️</a> <a href="https://github.com/HMCore/Core/commits?author=wulkanat" title="Code">💻</a> <a href="https://github.com/HMCore/Core/commits?author=wulkanat" title="Documentation">📖</a><a href="#ideas-wulkanat" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/UnrealValentin"><img src="https://avatars.githubusercontent.com/u/30842467?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UnrealValentin</b></sub></a><br /><a href="https://github.com/HMCore/Core/commits?author=UnrealValentin" title="Documentation">📖</a> <a href="https://github.com/HMCore/Core/commits?author=UnrealValentin" title="Tests">⚠️</a> <a href="https://github.com/HMCore/Core/commits?author=UnrealValentin" title="Code">💻</a> <a href="#ideas-UnrealValentin" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
||||
@@ -19,7 +19,7 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib"
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.hmcore.registration.config;
|
||||
|
||||
public class ModuleInfo {
|
||||
|
||||
public final String moduleName;
|
||||
public final ObjectInfoData[] objects;
|
||||
|
||||
public ModuleInfo(String moduleName, ObjectInfoData[] objects) {
|
||||
this.moduleName = moduleName;
|
||||
this.objects = objects;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package org.hmcore.registration.config;
|
||||
|
||||
public class ObjectInfoConfig {
|
||||
|
||||
public final ModuleInfo[] modules;
|
||||
|
||||
public ObjectInfoConfig(ModuleInfo[] modules) {
|
||||
this.modules = modules;
|
||||
}
|
||||
}
|
||||
@@ -43,10 +43,10 @@ public class ObjectInfoConfigHandler {
|
||||
RegistryModule<?, ?> registryModule = (RegistryModule<?, ?>) module;
|
||||
for (ObjectInfoData data:
|
||||
moduleInfo.objects) {
|
||||
if(registryModule.objectAndInfoExist(data.objectName, data.objectInfoChoosen)) {
|
||||
registryModule.forceObjectInfoForObject(data.objectName, data.objectInfoChoosen);
|
||||
if(registryModule.objectAndInfoExist(data.objectInfoName, data.objectInfoChosen)) {
|
||||
registryModule.forceObjectInfoForObject(data.objectInfoName, data.objectInfoChosen);
|
||||
} else {
|
||||
System.out.println("[!] Either Object Info " + data.objectInfoChoosen + " doesn't exist for " + data.objectName + " or " + data.objectName + " doesn't exist!\n" +
|
||||
System.out.println("[!] Either Object Info " + data.objectInfoChosen + " doesn't exist for " + data.objectInfoName + " or " + data.objectInfoName + " doesn't exist!\n" +
|
||||
"Please stop the Server, delete objetc-infos.json and let the server regenertate a new config [!]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.hmcore.registration.config;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ObjectInfoData {
|
||||
|
||||
public final String objectName;
|
||||
public final String objectInfoChoosen;
|
||||
public final String _availableOptions;
|
||||
|
||||
public ObjectInfoData(String objectName, @Nullable String objectInfoChoosen, String availableOptions) {
|
||||
this.objectName = objectName;
|
||||
this.objectInfoChoosen = objectInfoChoosen == null ? "default" : objectInfoChoosen;
|
||||
_availableOptions = availableOptions;
|
||||
}
|
||||
}
|
||||
7
src/main/kotlin/extensions/Array.kt
Normal file
7
src/main/kotlin/extensions/Array.kt
Normal file
@@ -0,0 +1,7 @@
|
||||
package extensions
|
||||
|
||||
/**
|
||||
* Map a Java array to another Java array
|
||||
*/
|
||||
inline fun <T, reified I> Array<T>.map(crossinline transform: (T) -> I) =
|
||||
Array(size) { transform(this[it]) }
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.hmcore.registration.config
|
||||
|
||||
internal class ModuleInfo(
|
||||
@JvmField val moduleName: String,
|
||||
@JvmField val objects: Array<ObjectInfoData>,
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.hmcore.registration.config
|
||||
|
||||
internal class ObjectInfoConfig(
|
||||
@JvmField val modules: Array<ModuleInfo>,
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
@file:JvmName("ObjectInfoConfigHandler")
|
||||
|
||||
package org.hmcore.registration.config
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import org.hmcore.modules.Module
|
||||
import extensions.map
|
||||
|
||||
private val GSON = GsonBuilder().setPrettyPrinting().create()
|
||||
|
||||
internal fun Array<Module<*, *>>.generateFreshJSON(): String =
|
||||
GSON.toJson(ObjectInfoConfig(map { ModuleInfo(it.name, it.objectInfoArray) }))
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.hmcore.registration.config
|
||||
|
||||
internal class ObjectInfoData @JvmOverloads constructor(
|
||||
@JvmField val objectInfoName: String,
|
||||
@JvmField val availableOptions: String,
|
||||
@JvmField val objectInfoChosen: String = "default",
|
||||
)
|
||||
@@ -12,6 +12,7 @@ import java.io.FileNotFoundException;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SuppressWarnings("KotlinInternalInJava")
|
||||
public class JavaTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("KotlinInternalInJava")
|
||||
public class JavaTestRegistryModule extends RegistryModule<Integer, JavaCustomObjectInfo> {
|
||||
|
||||
public HashMap<String, Integer> objectMap = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user