From 94208a77df0a89d790471ddb2957b90c8e513a97 Mon Sep 17 00:00:00 2001 From: FirstMegaGame4 <84094287+FirstMegaGame4@users.noreply.github.com> Date: Wed, 27 Dec 2023 00:33:18 +0100 Subject: [PATCH] Change EnvJsonUtils --- .../env/json/impl/EnvJsonUtils.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/firstmegagame4/env/json/impl/EnvJsonUtils.java b/src/main/java/fr/firstmegagame4/env/json/impl/EnvJsonUtils.java index f61c8f7..ca02acb 100644 --- a/src/main/java/fr/firstmegagame4/env/json/impl/EnvJsonUtils.java +++ b/src/main/java/fr/firstmegagame4/env/json/impl/EnvJsonUtils.java @@ -35,18 +35,23 @@ public static boolean isEnvJson(Identifier identifier) { return identifier.getPath().endsWith(".env.json"); } - public static String getFileExtension(Identifier identifier) { - return identifier.getPath().substring(identifier.getPath().lastIndexOf(".")); - } - public static Identifier getEnvJsonFileName(Identifier identifier) { - return identifier.withPath(identifier.getPath().substring(0, identifier.getPath().length() - ".env.json".length())); + String path; + if (identifier.getPath().contains("-")) { + int index = identifier.getPath().lastIndexOf("-"); + path = identifier.getPath().substring(0, index) + "." + identifier.getPath().substring(index + 1); + } + else { + path = identifier.getPath(); + } + return identifier.withPath(path.substring(0, path.length() - ".env.json".length())); } public static Identifier getEnvJsonPath(Identifier identifier) { String path; if (identifier.getPath().contains(".")) { - path = identifier.getPath().substring(0, identifier.getPath().lastIndexOf(".")); + int index = identifier.getPath().lastIndexOf("."); + path = identifier.getPath().substring(0, index) + "-" + identifier.getPath().substring(index + 1); } else { path = identifier.getPath();