mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -04:00
wip modding (2)
This commit is contained in:
parent
6d1e966619
commit
1fb09e8f40
@ -45,7 +45,7 @@ In your jar file (the mod) must be a file called `mod.json`.
|
|||||||
- `versionName`, `authors`, `name` is the classic implementation of metadata. Can be anything, will be displayed in the mod list. **Required**
|
- `versionName`, `authors`, `name` is the classic implementation of metadata. Can be anything, will be displayed in the mod list. **Required**
|
||||||
- `identifier` is the prefix of items (for Minecraft it is `minecraft`). Aka the thing before the `:`. **Required**
|
- `identifier` is the prefix of items (for Minecraft it is `minecraft`). Aka the thing before the `:`. **Required**
|
||||||
- `mainClass` the Main class of your mod (self explaining). The main class needs to extent the abstract class `MinosoftMod`. **Required**
|
- `mainClass` the Main class of your mod (self explaining). The main class needs to extent the abstract class `MinosoftMod`. **Required**
|
||||||
`loading` Loading attributes. **Optional**
|
- `loading` Loading attributes. **Optional**
|
||||||
- `priority` should the mod be loaded at the beginning or at the end. Possible values are `LOWEST`, `LOW`, `NORMAL`, `HIGH`, `HIGHEST` **Optional**
|
- `priority` should the mod be loaded at the beginning or at the end. Possible values are `LOWEST`, `LOW`, `NORMAL`, `HIGH`, `HIGHEST` **Optional**
|
||||||
- `dependencies` Used if you need an other mod to work **Optional**
|
- `dependencies` Used if you need an other mod to work **Optional**
|
||||||
- `hard` These mods are **needed** to work. If the loading fails, your mod is not getting loaded and an warning message is being displayed. **Optional**
|
- `hard` These mods are **needed** to work. If the loading fails, your mod is not getting loaded and an warning message is being displayed. **Optional**
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.modding.loading;
|
||||||
|
|
||||||
|
public class LoadingInfo {
|
||||||
|
LoadingPriorities loadingPriority;
|
||||||
|
|
||||||
|
public LoadingInfo(LoadingPriorities loadingPriority) {
|
||||||
|
this.loadingPriority = loadingPriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadingInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadingPriorities getLoadingPriority() {
|
||||||
|
return loadingPriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoadingPriority(LoadingPriorities loadingPriority) {
|
||||||
|
this.loadingPriority = loadingPriority;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.modding.loading;
|
||||||
|
|
||||||
|
public enum LoadingPriorities {
|
||||||
|
LOWEST,
|
||||||
|
LOW,
|
||||||
|
NORMAL,
|
||||||
|
HIGH,
|
||||||
|
HIGHEST
|
||||||
|
}
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.modding;
|
package de.bixilon.minosoft.modding.loading;
|
||||||
|
|
||||||
interface MinosoftModInterface {
|
interface MinosoftModInterface {
|
||||||
boolean start(ModPhases phase);
|
boolean start(ModPhases phase);
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.modding.loading;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import de.bixilon.minosoft.util.Util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ModInfo {
|
||||||
|
final UUID uuid;
|
||||||
|
final int versionId;
|
||||||
|
final String versionName;
|
||||||
|
final String name;
|
||||||
|
final String[] authors;
|
||||||
|
final String identifier;
|
||||||
|
final String mainClass;
|
||||||
|
LoadingInfo info;
|
||||||
|
|
||||||
|
public ModInfo(JsonObject json) {
|
||||||
|
this.uuid = Util.uuidFromString(json.get("uuid").getAsString());
|
||||||
|
this.versionId = json.get("versionId").getAsInt();
|
||||||
|
this.versionName = json.get("versionName").getAsString();
|
||||||
|
this.name = json.get("name").getAsString();
|
||||||
|
JsonArray authors = json.get("authors").getAsJsonArray();
|
||||||
|
this.authors = new String[authors.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (JsonElement authorElement : authors) {
|
||||||
|
this.authors[i] = authorElement.getAsString();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
this.identifier = json.get("identifier").getAsString();
|
||||||
|
this.mainClass = json.get("mainClass").getAsString();
|
||||||
|
if (json.has("loading")) {
|
||||||
|
JsonObject loading = json.getAsJsonObject("loading");
|
||||||
|
this.info = new LoadingInfo();
|
||||||
|
if (loading.has("priority")) {
|
||||||
|
this.info.setLoadingPriority(LoadingPriorities.valueOf(loading.get("priority").getAsString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersionId() {
|
||||||
|
return versionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersionName() {
|
||||||
|
return versionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdentifier() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMainClass() {
|
||||||
|
return mainClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadingInfo getInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.modding;
|
package de.bixilon.minosoft.modding.loading;
|
||||||
|
|
||||||
public enum ModPhases {
|
public enum ModPhases {
|
||||||
BOOTING,
|
BOOTING,
|
@ -28,10 +28,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.DataFormatException;
|
import java.util.zip.*;
|
||||||
import java.util.zip.Deflater;
|
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
import java.util.zip.Inflater;
|
|
||||||
|
|
||||||
public final class Util {
|
public final class Util {
|
||||||
public static final Pattern UUID_FIX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); // thanks https://www.spigotmc.org/threads/free-code-easily-convert-between-trimmed-and-full-uuids.165615
|
public static final Pattern UUID_FIX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); // thanks https://www.spigotmc.org/threads/free-code-easily-convert-between-trimmed-and-full-uuids.165615
|
||||||
@ -159,6 +156,14 @@ public final class Util {
|
|||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String readFileFromZip(String fileName, ZipFile zipFile) throws IOException {
|
||||||
|
return readFile(new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipFile.getEntry(fileName)))), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonObject readJsonFromZip(String fileName, ZipFile zipFile) throws IOException {
|
||||||
|
return JsonParser.parseString(readFileFromZip(fileName, zipFile)).getAsJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
public static String readFile(File file) throws IOException {
|
public static String readFile(File file) throws IOException {
|
||||||
return readFile(new BufferedReader(new FileReader(file)), true);
|
return readFile(new BufferedReader(new FileReader(file)), true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user