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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'fr.openmc.riftengine'
version = '0.4-SNAPSHOT'
version = '0.5-SNAPSHOT'

repositories {
mavenCentral()
Expand Down
Binary file modified libs/OpenMC.jar
Binary file not shown.
8 changes: 7 additions & 1 deletion src/main/java/fr/openmc/riftengine/core/RiftLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public enum RiftLog {
NUMBER_GLYPH_REGISTERED("{}/{} glyphs enregistré", LogType.INFO),

ITEM_NOT_RESOURCE("Item {} : n'a pas de best resources", LogType.WARN),
RESOURCE_NOT_FOUND("Item {} : a aucune resource", LogType.WARN)
RESOURCE_NOT_FOUND("Item {} : a aucune resource", LogType.WARN),
NUMBER_TOOLTIP_REGISTERED("{}/{} tooltip enregistré", LogType.INFO),
GLYPH_NOT_FOUND("Glyph {} introuvable", LogType.WARN),
FLIPBOOK_NULL("Flipbook est null pour ce tooltip {}", LogType.WARN),
NULL("{} est null", LogType.WARN),

PATH_CANT_REDUCED_TO_TEXTURES("resource {} ne peut pas etre réduite à un chemin de texture", LogType.WARN),
;

public static void logBanner(String pluginVersion, String server, String javaVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@
import fr.openmc.riftengine.core.converter.writers.manifest.IconWriter;
import fr.openmc.riftengine.core.converter.writers.manifest.ManifestWriter;
import fr.openmc.riftengine.core.converter.writers.manifest.PackIdentity;
import fr.openmc.riftengine.core.converter.writers.sounds.SoundsDefinitionsJsonWriter;
import fr.openmc.riftengine.core.converter.writers.sounds.SoundsFileWriter;
import fr.openmc.riftengine.core.converter.writers.tooltip.UiCommonTooltipWriter;
import fr.openmc.riftengine.core.converter.writers.tooltip.glyph.TooltipGlyphApplicatorWriter;
import fr.openmc.riftengine.core.converter.writers.tooltip.glyph.TooltipGlyphAssignatorWriter;
import fr.openmc.riftengine.core.converter.writers.tooltip.textures.TooltipTextureWriter;
import fr.openmc.riftengine.core.converter.writers.translations.TranslationInjector;
import fr.openmc.riftengine.core.converter.writers.ui.ScoreboardUiWriter;
import fr.openmc.riftengine.core.resolvers.items.ItemResourceResolver;
import fr.openmc.riftengine.core.resolvers.mcmeta.animation.AnimationMcMetaResolver;
import fr.openmc.riftengine.core.resolvers.mcmeta.gui.GuiMcMetaResolver;
import fr.openmc.riftengine.core.resolvers.tooltip.TooltipResourceResolver;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
Expand All @@ -45,7 +54,11 @@ public ConverterManager(RiftPlugin plugin) {
try {
PackIdentity identity = PackIdentity.loadOrCreate(plugin);
List<ItemEntry> items = OMCRegistry.SCANNERS.ITEMS.scan(itemsAdderContents);
ItemResourceResolver resolver = RiftRegistry.RESOLVERS.ITEM_RESOURCE_RESOLVER;

ItemResourceResolver itemResolver = RiftRegistry.RESOLVERS.ITEM_RESOURCE_RESOLVER;
TooltipResourceResolver tooltipResolver = RiftRegistry.RESOLVERS.TOOLTIP_RESOURCE_RESOLVER;
GuiMcMetaResolver guiResolver = RiftRegistry.RESOLVERS.GUI_MCMETA_RESOLVER;
AnimationMcMetaResolver animResolver = RiftRegistry.RESOLVERS.ANIMATION_MCMETA_RESOLVER;

register("Icônes", new IconWriter());
register("Manifest", new ManifestWriter(identity));
Expand All @@ -55,16 +68,27 @@ public ConverterManager(RiftPlugin plugin) {
register("Scoreboard",
new ScoreboardUiWriter(config.isHideScoreboardNumberBedrock()));

register("Sounds Definitions Json", new SoundsDefinitionsJsonWriter());
register("Sounds File", new SoundsFileWriter());

register("Icônes ItemsAdder", new IconsWriter(itemsAdderContents));
register("Mappings des symboles", new SymbolWriter());

register("Textures des items", new ItemsTextureJsonWriter(items, resolver));
register("Fichiers de textures", new ItemsTextureWriter(items, resolver));
register("Mappings des items", new ItemsMappingWriter(items, resolver));
register("Textures des items", new ItemsTextureJsonWriter(items, itemResolver));
register("Fichiers de textures", new ItemsTextureWriter(items, itemResolver));
register("Mappings des items", new ItemsMappingWriter(items, itemResolver));

register("Textures des tooltips", new TooltipTextureWriter(items, guiResolver, tooltipResolver));
register("Assignations des glyphs pour les tooltips",
new TooltipGlyphAssignatorWriter(items, tooltipResolver));
register("Application des glyphs sur les items",
new TooltipGlyphApplicatorWriter(items, itemsAdderContents));
register("Génération du JSON UI pour les tooltips",
new UiCommonTooltipWriter(items, tooltipResolver, guiResolver, animResolver));

register("Textures des blocs",
new TerrainTextureJsonWriter(identity, items, resolver));
register("Mappings des blocs", new BlocksMappingWriter(items, resolver));
new TerrainTextureJsonWriter(identity, items, itemResolver));
register("Mappings des blocs", new BlocksMappingWriter(items, itemResolver));

} catch (Exception e) {
throw new RuntimeException("Erreur lors d'initialisation du ConverterManager", e);
Expand Down Expand Up @@ -108,9 +132,13 @@ public static Path getJavaPackPath(JavaPlugin plugin) {
File pluginsDir = plugin.getDataFolder().getParentFile(); // * root/plugins/
File itemsAdderDir = new File(pluginsDir, "ItemsAdder"); // * root/plugins/ItemsAdder
File outputDir = new File(itemsAdderDir, "output"); // * root/plugins/ItemsAdder/output
File generatedDir = new File(outputDir, "generated.zip"); // * root/plugins/ItemsAdder/output/generated.zip
File clientPacksDir = new File(outputDir, "client_packs"); // * root/plugins/ItemsAdder/output/client_packs/

return generatedDir.toPath();
return FilesUtils.listFileNames(clientPacksDir.toPath().toAbsolutePath().toString()).stream()
.filter(name -> name.contains(".zip") && name.contains("26_3") && name.contains("fast_compression"))
.findFirst()
.map(name -> clientPacksDir.toPath().resolve(name))
.orElse(null);
}

public static Path getItemsAdderContents(JavaPlugin plugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public interface PackWriter {
void write(Path bedrockRootPath, Path javaRootPath) throws Exception;

default void writeJsonFile(Path outputFile, JsonObject root) throws IOException {
this.writeFile(outputFile, GSON.toJson(root));
this.writeJsonFile(outputFile, root, GSON);
}

default void writeJsonFile(Path outputFile, JsonObject root, Gson gson) throws IOException {
this.writeFile(outputFile, gson.toJson(root));
}

default void writeFile(Path outputFile, String content) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import fr.openmc.core.utils.YmlUtils;
import fr.openmc.riftengine.core.RiftLog;
import fr.openmc.riftengine.core.RiftPlugin;
import fr.openmc.riftengine.core.RiftRegistry;
import fr.openmc.riftengine.core.converter.writers.PackWriter;
import fr.openmc.riftengine.core.listeners.LoadAfterItemsAdderListener;
import fr.openmc.riftengine.core.registry.glyphs.Glyph;
import fr.openmc.riftengine.core.registry.glyphs.types.IconGlyph;
import org.bukkit.Bukkit;
import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
Expand Down Expand Up @@ -67,12 +65,6 @@ public void write(Path bedrockRootPath, Path javaRootPath) throws IOException {
}
}

LoadAfterItemsAdderListener.actionToLaunch.add(this::reloadItemsAdder);
}

private void reloadItemsAdder() {
Bukkit.getScheduler().runTask(RiftPlugin.getInstance(), () ->
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "iazip")
);
LoadAfterItemsAdderListener.reloadToLaunch = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ public void write(Path bedrockRootPath, Path javaRootPath) throws IOException {

Files.copy(is, bedrockRootPath.resolve(OUTPUT_FILE), StandardCopyOption.REPLACE_EXISTING);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package fr.openmc.riftengine.core.converter.writers.sounds;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import fr.openmc.core.OMCRegistry;
import fr.openmc.riftengine.api.scanner.sounds.SoundEntry;
import fr.openmc.riftengine.core.converter.writers.PackWriter;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

/**
* Ecrit le sounds_definitions.json qui sert grosso modo a relier les textures aux items (une ref = une resource)
*/
public class SoundsDefinitionsJsonWriter implements PackWriter {
private static final String OUTPUT_FILE = "sounds/sound_definitions.json";

@Override
public void write(Path bedrockRootPath, Path javaRootPath) throws IOException {
List<SoundEntry> sounds = OMCRegistry.SCANNERS.SOUNDS.scan(javaRootPath);
JsonObject definitions = new JsonObject();

for (SoundEntry entry : sounds) {
JsonArray array = new JsonArray();
for (String resourceId : entry.soundResourcesId()) {
if (resourceId == null) continue;
array.add(entry.toBedrockPath("minecraft", resourceId));
}
if (array.isEmpty()) continue;

JsonObject def = new JsonObject();
def.addProperty("category", "player");
def.add("sounds", array);
definitions.add(entry.toBedrockEventId(), def);
}

JsonObject root = new JsonObject();
root.addProperty("format_version", "1.21.50");
root.add("sound_definitions", definitions);

Path outputFile = bedrockRootPath.resolve(OUTPUT_FILE);
this.writeJsonFile(outputFile, root);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package fr.openmc.riftengine.core.converter.writers.sounds;

import fr.openmc.core.OMCRegistry;
import fr.openmc.riftengine.api.scanner.sounds.SoundEntry;
import fr.openmc.riftengine.core.converter.writers.PackWriter;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

public class SoundsFileWriter implements PackWriter {
@Override
public void write(Path bedrockRootPath, Path javaRootPath) throws IOException {
List<SoundEntry> sounds = OMCRegistry.SCANNERS.SOUNDS.scan(javaRootPath);

for (SoundEntry soundEntry : sounds) {
for (String soundResourceId : soundEntry.soundResourcesId()) {
Path soundsPath = javaRootPath.resolve(soundEntry.toJavaPath("minecraft", soundResourceId) + ".ogg");
Path dest = bedrockRootPath.resolve(soundEntry.toBedrockPath("minecraft", soundResourceId) + ".ogg");

this.copyFile(soundsPath, dest);
}
}
}
}
Loading
Loading