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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,7 @@ spigot.yml
.project
.settings/
bin/
!libs/
!libs/

# local.properties
local.properties
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,28 @@ processResources {
filesMatching('paper-plugin.yml') {
expand(pluginProps)
}
}

// * Propriété locale
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')

if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream {
localProperties.load(it)
}
}

tasks.jar {
destinationDirectory.set(file('./builds/'))
}

tasks.register('copyJarToServer', Copy) {
dependsOn tasks.jar

from tasks.jar

if (localProperties.getProperty('minecraftServerDir')) {
into file("${localProperties.getProperty('minecraftServerDir')}/plugins")
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# NMS & paper lib
paperWeightUserDevVersion = 2.0.0-beta.23
paperWeightUserDevVersion = 2.0.0-beta.24

# Paper version
minecraftVersion = 26.2
paperVersion = 118-stable
minecraftVersion = 26.3
paperVersion = 180-stable

# Dependencies versions
itemsAdderVersion = 4.0.18-beta-10
Expand Down
Binary file modified libs/OpenMC.jar
Binary file not shown.
5 changes: 0 additions & 5 deletions src/main/java/fr/openmc/riftengine/core/RiftRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import fr.openmc.core.bootstrap.registries.RegistryContext;
import fr.openmc.core.bootstrap.registries.RegistryLoadingType;
import fr.openmc.riftengine.core.registry.glyphs.GlyphsRegistry;
import fr.openmc.riftengine.core.registry.scanner.ScannerRegistry;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -15,16 +14,12 @@
public final class RiftRegistry {
// * Registre globaux
public static GlyphsRegistry GLYPHS;
public static ScannerRegistry SCANNERS;

private static final List<LifecycleRegistry> LOADED = new ArrayList<>();

private static final List<RegistryContext> ALL = List.of(
new RegistryContext(
() -> GLYPHS = new GlyphsRegistry(),
RegistryLoadingType.RUNTIME),
new RegistryContext(
() -> SCANNERS = new ScannerRegistry(),
RegistryLoadingType.RUNTIME)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import fr.openmc.core.OMCRegistry;
import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.utils.FilesUtils;
import fr.openmc.core.utils.ZipUtils;
import fr.openmc.riftengine.api.scanner.items.ItemEntry;
import fr.openmc.riftengine.core.RiftConfig;
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.converter.writers.glyph.font.FontWriter;
import fr.openmc.riftengine.core.converter.writers.glyph.icons.IconsWriter;
Expand All @@ -18,12 +19,9 @@
import fr.openmc.riftengine.core.converter.writers.manifest.PackIdentity;
import fr.openmc.riftengine.core.converter.writers.translations.TranslationInjector;
import fr.openmc.riftengine.core.converter.writers.ui.ScoreboardUiWriter;
import fr.openmc.riftengine.core.scanner.items.ItemEntry;
import fr.openmc.riftengine.core.utils.ZipUtils;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand All @@ -44,7 +42,7 @@ public ConverterManager(RiftPlugin plugin) {

try {
identity = PackIdentity.loadOrCreate(plugin);
List<ItemEntry> items = RiftRegistry.SCANNERS.ITEMS.scan(itemsAdderContents);
List<ItemEntry> items = OMCRegistry.SCANNERS.ITEMS.scan(itemsAdderContents);
writers.addAll(List.of(
new IconWriter(),
new ManifestWriter(identity),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.openmc.riftengine.core.converter.writers.glyph.icons;

import fr.openmc.riftengine.core.scanner.icons.IconEntry;
import fr.openmc.riftengine.api.scanner.icons.IconEntry;

import java.awt.*;

Expand Down Expand Up @@ -81,6 +81,25 @@ public int yOffset(IconEntry entry, int height) {
}
},


// todo: faire un EMOJI_{x} avec x un entier
EMOJI_13 {
@Override
public boolean matches(int width, int height) {
return false; // a detecter manuellement via config/icons_type.yml
}

@Override
public Dimension finalSize(IconEntry entry, int width, int height) {
return new Dimension(13, 13);
}

@Override
public int yOffset(IconEntry entry, int height) {
return entry.yPosition() != null ? -entry.yPosition() : DEFAULT_Y_OFFSET;
}
},

EMOJI_16 {
@Override
public boolean matches(int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package fr.openmc.riftengine.core.converter.writers.glyph.icons;

import fr.openmc.core.OMCRegistry;
import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.riftengine.api.scanner.icons.IconEntry;
import fr.openmc.riftengine.api.scanner.icons.IconScanner;
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.registry.glyphs.GlyphsRegistry;
import fr.openmc.riftengine.core.registry.glyphs.types.IconGlyph;
import fr.openmc.riftengine.core.scanner.icons.IconEntry;
import fr.openmc.riftengine.core.scanner.icons.IconScanner;

import javax.imageio.ImageIO;
import java.awt.*;
Expand All @@ -34,9 +35,9 @@ public IconsWriter(Path itemsAdderContentsPath) {
@Override
public void write(Path bedrockRootPath, Path javaRootPath) throws IOException {
IconsTypeConfig forcedType = IconsTypeConfig.load(RiftPlugin.getInstance().CONFIG_FOLDER
.resolve("icons_types.yml"));
.resolve("icons_types.yml")); // todo: degeu ça

IconScanner scanner = RiftRegistry.SCANNERS.ICONS;
IconScanner scanner = OMCRegistry.SCANNERS.ICONS;
List<IconEntry> entries;
try {
entries = scanner.scan(itemsAdderContentsPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package fr.openmc.riftengine.core.converter.writers.glyph.icons;

import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.utils.YmlUtils;
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 fr.openmc.riftengine.core.utils.YmlUtils;
import org.bukkit.Bukkit;
import org.yaml.snakeyaml.Yaml;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.riftengine.api.scanner.items.ItemEntry;
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.scanner.items.ItemEntry;
import fr.openmc.riftengine.core.utils.PathUtils;
import org.bukkit.Material;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -39,24 +35,24 @@ public void write(Path bedrockRootPath, Path javaRootPath) throws Exception {
Map<String, JsonArray> byMaterial = new HashMap<>();

for (ItemEntry item : items) {
JsonObject def = new JsonObject();
Map<String, String> resources = item.getBestResourcesId();

if (item.getCustomModelData() != null) {
def.addProperty("type", "legacy");
def.addProperty("custom_model_data", item.getCustomModelData());
if (resources == null) continue;

if (resources.size() == 1) {
// * Gestion des items a une texture
byMaterial.computeIfAbsent(item.getMaterial().getKey().asString(), _ -> new JsonArray())
.add(handleUniqueTexture(item));
} else {
def.addProperty("type", "definition");
// * Gestion des items a plusieurs textures
JsonObject def = new JsonObject();
def.addProperty("type", "group");
def.addProperty("model", item.getNamespace() + ":ia_auto/" + item.getKey());
}
def.add("definitions", handleMultipleTexture(item));

def.addProperty("bedrock_identifier", item.namespacedId());

JsonObject options = new JsonObject();
options.addProperty("icon", item.namespacedId());
def.add("bedrock_options", options);

byMaterial.computeIfAbsent(item.getMaterial().getKey().asString(), _ -> new JsonArray())
.add(def);
byMaterial.computeIfAbsent(item.getMaterial().getKey().asString(), _ -> new JsonArray())
.add(def);
}
}

JsonObject itemsSetter = new JsonObject();
Expand All @@ -69,9 +65,66 @@ public void write(Path bedrockRootPath, Path javaRootPath) throws Exception {
Files.writeString(outputFile, GSON.toJson(root), StandardCharsets.UTF_8);
}

private ItemEntry getByNamespace(String namespacedId) {
return items.stream().
filter(item -> item.namespacedId().equals(namespacedId))
.findFirst().orElse(null);
private JsonObject handleUniqueTexture(ItemEntry item) {
JsonObject def = new JsonObject();
if (item.getCustomModelData() != null) {
def.addProperty("type", "legacy");
def.addProperty("custom_model_data", item.getCustomModelData());
} else {
def.addProperty("type", "definition");
def.addProperty("model", item.getNamespace() + ":ia_auto/" + item.getKey());
}

def.addProperty("bedrock_identifier", item.namespacedId());

JsonObject options = new JsonObject();
options.addProperty("icon", item.namespacedId());
def.add("bedrock_options", options);

return def;
}

private JsonArray handleMultipleTexture(ItemEntry item) {
JsonArray definitionsArray = new JsonArray();

Map<String, String> bestResources = item.getBestResourcesId();
if (bestResources == null) {
OMCLogger.warn("Item {} : n'a pas de best resources", item.namespacedId());
return definitionsArray;
}

for (var entry : bestResources.entrySet()) {
String stateResource = entry.getKey();

JsonObject defObject = new JsonObject();

String namespaceId = item.namespacedId();

if (!stateResource.equals("normal"))
namespaceId += "_" + stateResource;

defObject.addProperty("bedrock_identifier", namespaceId);

JsonObject options = new JsonObject();
options.addProperty("icon", namespaceId);
options.addProperty("display_handheld", true);

// y'a 5 types de conditions (broken, damaged, custom_model_data, has_component, fishing_rod_cast),
// note pour plus tard si ajout elytra
if (!stateResource.equals("normal") && item.getMaterial().equals(Material.FISHING_ROD)) {
options.addProperty("display_handheld", true);
JsonObject predicate = new JsonObject();
predicate.addProperty("type", "condition");
predicate.addProperty("property", "fishing_rod_cast");
defObject.add("predicate", predicate);
}


defObject.add("bedrock_options", options);

definitionsArray.add(defObject);
}

return definitionsArray;
}
}
Loading
Loading