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
21 changes: 21 additions & 0 deletions .github/scripts/install-local-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
# Run from the repository root after downloading the pinned JARs.
# Hash-qualified versions prevent different private JARs sharing a Maven cache key.
sha256sum --check .github/dependencies.sha256

mvn -B --no-transfer-progress org.apache.maven.plugins:maven-install-plugin:3.1.4:install-file \
-Dfile="libs/gson-2.10.1.jar" -DgroupId="local" -DartifactId="gson" \
-Dversion="2.10.1-tfmc-4241c14a7727" -Dpackaging=jar -DgeneratePom=true "$@"
mvn -B --no-transfer-progress org.apache.maven.plugins:maven-install-plugin:3.1.4:install-file \
-Dfile="libs/json-simple-1.1.jar" -DgroupId="local" -DartifactId="json-simple" \
-Dversion="1.1-tfmc-2d9484f4c649" -Dpackaging=jar -DgeneratePom=true "$@"
mvn -B --no-transfer-progress org.apache.maven.plugins:maven-install-plugin:3.1.4:install-file \
-Dfile="libs/MMOItems-6.10.jar" -DgroupId="local" -DartifactId="MMOItems" \
-Dversion="6.10-tfmc-c84700df5942" -Dpackaging=jar -DgeneratePom=true "$@"
mvn -B --no-transfer-progress org.apache.maven.plugins:maven-install-plugin:3.1.4:install-file \
-Dfile="libs/MythicLib-1.7.jar" -DgroupId="local" -DartifactId="MythicLib" \
-Dversion="1.7-tfmc-660ff2a6ec86" -Dpackaging=jar -DgeneratePom=true "$@"
mvn -B --no-transfer-progress org.apache.maven.plugins:maven-install-plugin:3.1.4:install-file \
-Dfile="libs/ItemsAdder_3.5.0-r2.jar" -DgroupId="local" -DartifactId="LoneLibs" \
-Dversion="3.5.0-tfmc-0116d714822b" -Dpackaging=jar -DgeneratePom=true "$@"
2 changes: 1 addition & 1 deletion .github/scripts/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/c84700df5942/MMOItems-6.10.jar?ref=$ref" > "libs/MMOItems-6.10.jar"
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/660ff2a6ec86/MythicLib-1.7.jar?ref=$ref" > "libs/MythicLib-1.7.jar"
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/0116d714822b/ItemsAdder_3.5.0-r2.jar?ref=$ref" > "libs/ItemsAdder_3.5.0-r2.jar"
sha256sum --check .github/dependencies.sha256
bash .github/scripts/install-local-dependencies.sh "$@"
25 changes: 10 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,26 @@
<dependency>
<groupId>local</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/gson-2.10.1.jar</systemPath>
<version>2.10.1-tfmc-4241c14a7727</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/json-simple-1.1.jar</systemPath>
<version>1.1-tfmc-2d9484f4c649</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>MMOItems</artifactId>
<version>6.10</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/MMOItems-6.10.jar</systemPath>
<version>6.10-tfmc-c84700df5942</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>MythicLib</artifactId>
<version>1.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/MythicLib-1.7.jar</systemPath>
<version>1.7-tfmc-660ff2a6ec86</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
Expand All @@ -65,9 +61,8 @@
<dependency>
<groupId>local</groupId>
<artifactId>LoneLibs</artifactId>
<version>3.5.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/ItemsAdder_3.5.0-r2.jar</systemPath>
<version>3.5.0-tfmc-0116d714822b</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -82,13 +83,9 @@ private void saveForgedIds(UUID playerUuid, Set<String> forged) {
CACHE.put(playerUuid, forged);

File file = playerFile(playerUuid);
JSONArray array = new JSONArray();
for (String id : forged) {
array.add(id);
}

try (PrintWriter writer = new PrintWriter(new FileWriter(file, false))) {
writer.print(array.toJSONString());
writer.print(JSONArray.toJSONString(new ArrayList<>(forged)));
writer.flush();
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import dev.lone.itemsadder.api.CustomStack;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.BlockAPI;
import net.tfminecraft.tlibs.objects.api.subapi.StringFormatter;
import net.tfminecraft.advancedcrafting.AdvancedCrafting;
Expand Down Expand Up @@ -71,7 +70,7 @@ public void removeStation(AlloyStation station) {

public boolean isAlloyStation(Block b) {
String path = Cache.alloyStation;
BlockAPI api = (BlockAPI) TLibs.getApiInstance(APIType.BLOCK_API);
BlockAPI api = TLibs.getBlockAPI();
return api.getChecker().checkBlock(b, path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import dev.lone.itemsadder.api.Events.FurnitureBreakEvent;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.BlockAPI;
import net.tfminecraft.tlibs.objects.api.ItemAPI;
import net.tfminecraft.advancedcrafting.AdvancedCrafting;
Expand Down Expand Up @@ -67,7 +66,7 @@ private boolean isCraftingStation(Block b) {
if (b == null || Cache.craftingStation == null) {
return false;
}
BlockAPI blockApi = (BlockAPI) TLibs.getApiInstance(APIType.BLOCK_API);
BlockAPI blockApi = TLibs.getBlockAPI();
return blockApi.getChecker().checkBlock(b, Cache.craftingStation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import dev.lone.itemsadder.api.CustomStack;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.BlockAPI;
import net.tfminecraft.advancedcrafting.cache.Cache;
import net.tfminecraft.advancedcrafting.objects.alloys.Alloy;
Expand All @@ -35,7 +34,7 @@ public Ingredient get(String path) {

public boolean isIngredientStation(Block b) {
String path = Cache.ingredientStation;
BlockAPI api = (BlockAPI) TLibs.getApiInstance(APIType.BLOCK_API);
BlockAPI api = TLibs.getBlockAPI();
return api.getChecker().checkBlock(b, path);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.tfminecraft.advancedcrafting.managers;

import net.tfminecraft.advancedcrafting.util.LegacyModelData;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -12,7 +14,6 @@
import org.bukkit.persistence.PersistentDataType;

import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.ItemAPI;
import net.tfminecraft.tlibs.objects.api.subapi.StringFormatter;
import net.tfminecraft.advancedcrafting.AdvancedCrafting;
Expand Down Expand Up @@ -129,14 +130,14 @@ private ItemStack getCategoryItem(RecipeCategory c) {
i.setItemMeta(m);
return i;
}
ItemAPI api = (ItemAPI) TLibs.getApiInstance(APIType.ITEM_API);
ItemAPI api = TLibs.getItemAPI();
ItemStack template = api.getCreator().getItemFromPath("m."+c.getRecipes().get(0).getTemplate());
if(template != null) {
i.setType(template.getType());
}
ItemMeta m = i.getItemMeta();
if(template != null && template.getItemMeta().hasCustomModelData()) {
m.setCustomModelData(template.getItemMeta().getCustomModelData());
if(template != null && LegacyModelData.has(template.getItemMeta())) {
LegacyModelData.set(m, LegacyModelData.get(template.getItemMeta()));
}
m.setDisplayName(c.getName());
List<String> lore = new ArrayList<>();
Expand All @@ -150,7 +151,7 @@ private ItemStack getCategoryItem(RecipeCategory c) {

private ItemStack getRecipeItem(CraftingRecipe r) {
ItemStack fallback = new ItemStack(Material.BARRIER, 1);
ItemAPI api = (ItemAPI) TLibs.getApiInstance(APIType.ITEM_API);
ItemAPI api = TLibs.getItemAPI();
String path = r.resolveMenuIconPath();
ItemStack base = api.getCreator().getItemFromPath(path);
if (base == null || (path.toLowerCase().startsWith("ia.") && base.getType() == Material.DIRT)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.tfminecraft.advancedcrafting.objects.alloys;

import net.tfminecraft.advancedcrafting.util.LegacyModelData;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -13,7 +15,6 @@

import io.lumine.mythic.lib.api.item.NBTItem;
import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.ItemAPI;
import net.tfminecraft.tlibs.objects.api.subapi.StringFormatter;
import net.Indyuce.mmoitems.ItemStats;
Expand Down Expand Up @@ -58,13 +59,13 @@ public Alloy(String id, String name, AlloyData data) {

@SuppressWarnings("deprecation")
public ItemStack build() {
ItemAPI api = (ItemAPI) TLibs.getApiInstance(APIType.ITEM_API);
ItemAPI api = TLibs.getItemAPI();
ItemStack template = api.getCreator().getItemFromPath(data.getColourScheme().getItem());
MMOItem mmo = new LiveMMOItem(NBTItem.get(template));
StringData itemName = (StringData) mmo.getData(ItemStats.NAME);
itemName.setString(name);
mmo.replaceData(ItemStats.NAME, itemName);
StatHistory hist = StatHistory.from(mmo, ItemStats.NAME);
StatHistory hist = mmo.computeStatHistory(ItemStats.NAME);
if (hist != null) {
NameData og = (NameData) hist.getOriginalData();
og.setString(name);
Expand All @@ -79,7 +80,7 @@ public ItemStack build() {
ItemMeta m = i.getItemMeta();
m.addEnchant(Enchantment.UNBREAKING, 1, true);
m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
m.setCustomModelData(data.getModel());
LegacyModelData.set(m, data.getModel());
m.getPersistentDataContainer().set(PDCKeys.alloyId(), PersistentDataType.STRING, id);
AcItemTags.write(m, revision, loreBlock);
i.setItemMeta(m);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.tfminecraft.advancedcrafting.objects.crafting;

import net.tfminecraft.advancedcrafting.util.LegacyModelData;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -17,7 +19,6 @@

import io.lumine.mythic.lib.api.item.NBTItem;
import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.ItemAPI;
import net.tfminecraft.tlibs.objects.utils.IntCounter;
import net.Indyuce.mmoitems.ItemStats;
Expand Down Expand Up @@ -386,7 +387,7 @@ private StationFeedback createItem(Player p, Double forcedQualityPercent) {
if (forcedQualityPercent == null && !checkHits(p)) {
return StationFeedback.LACKING_HITS;
}
ItemAPI api = (ItemAPI) TLibs.getApiInstance(APIType.ITEM_API);
ItemAPI api = TLibs.getItemAPI();
result = api.getCreator().getItemFromPath("m."+recipe.getTemplate());
MMOItem mmo = new LiveMMOItem(NBTItem.get(result));
MMOStatApplicator.applyExternalLayer(mmo, stats, CraftStatCalculator.collectManagedStatIds(recipe), true);
Expand Down Expand Up @@ -439,7 +440,7 @@ private StationFeedback createItem(Player p, Double forcedQualityPercent) {


mmo.replaceData(ItemStats.NAME, itemName);
StatHistory hist = StatHistory.from(mmo, ItemStats.NAME);
StatHistory hist = mmo.computeStatHistory(ItemStats.NAME);
if (hist != null) {
NameData og = (NameData) hist.getOriginalData();
og.setString(result);
Expand Down Expand Up @@ -507,10 +508,10 @@ private ItemStack applyModel(ItemStack i, ModelScheme scheme) {
if(type.equalsIgnoreCase("v")) {
i.setType(Material.valueOf(path.split("\\.")[1].toUpperCase()));
ItemMeta m = i.getItemMeta();
m.setCustomModelData(Integer.parseInt(path.split("\\.")[2]));
LegacyModelData.set(m, Integer.parseInt(path.split("\\.")[2]));
i.setItemMeta(m);
} else if(type.equalsIgnoreCase("ia")) {
ItemAPI api = (ItemAPI) TLibs.getApiInstance(APIType.ITEM_API);
ItemAPI api = TLibs.getItemAPI();
i = api.getArmorMerger().merge(i, Optional.empty(), path);
}
return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bukkit.persistence.PersistentDataType;

import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.enums.APIType;
import net.tfminecraft.tlibs.objects.api.ItemAPI;
import net.tfminecraft.tlibs.objects.api.subapi.StringFormatter;
import net.tfminecraft.advancedcrafting.objects.data.IngredientData;
Expand Down Expand Up @@ -80,7 +79,7 @@ public void buildTo(ItemStack i) {
}

public ItemStack build() {
ItemAPI api = (ItemAPI) TLibs.getApiInstance(APIType.ITEM_API);
ItemAPI api = TLibs.getItemAPI();
ItemStack i = api.getCreator().getItemFromPath(path);
buildTo(i);
return i;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.tfminecraft.advancedcrafting.util;

import java.util.List;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.CustomModelDataComponent;

/** Preserves the integer model IDs used by existing configuration and resource packs. */
public final class LegacyModelData {
private LegacyModelData() {}

public static boolean has(ItemMeta meta) {
return !meta.getCustomModelDataComponent().getFloats().isEmpty();
}

public static int get(ItemMeta meta) {
List<Float> floats = meta.getCustomModelDataComponent().getFloats();
if (floats.isEmpty()) {
throw new IllegalStateException("We don't have CustomModelData! Check hasCustomModelData first!");
}
return floats.get(0).intValue();
}

public static void set(ItemMeta meta, Integer value) {
if (value == null) {
meta.setCustomModelDataComponent(null);
return;
}
CustomModelDataComponent component = meta.getCustomModelDataComponent();
// The former integer setter replaced the entire component, not just its first float.
component.setFloats(List.of(value.floatValue()));
component.setFlags(List.of());
component.setStrings(List.of());
component.setColors(List.of());
meta.setCustomModelDataComponent(component);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static void clearExternalLayer(MMOItem mmo, Set<String> managedStatIds)
if (itemStat == null) {
continue;
}
StatHistory hist = StatHistory.from(mmo, itemStat);
StatHistory hist = mmo.computeStatHistory(itemStat);
if (hist != null) {
hist.clearExternalData();
mmo.setStatHistory(itemStat, hist);
Expand All @@ -110,7 +110,7 @@ private static void zeroOriginalLayer(MMOItem mmo, Set<String> managedStatIds) {
if (itemStat == null) {
continue;
}
StatHistory hist = StatHistory.from(mmo, itemStat);
StatHistory hist = mmo.computeStatHistory(itemStat);
if (hist != null) {
Object og = hist.getOriginalData();
if (og instanceof DoubleData doubleOg) {
Expand All @@ -124,7 +124,7 @@ private static void zeroOriginalLayer(MMOItem mmo, Set<String> managedStatIds) {

@SuppressWarnings("deprecation")
private static void registerExternal(MMOItem mmo, ItemStat<?, ?> itemStat, DoubleData data) {
StatHistory hist = StatHistory.from(mmo, itemStat);
StatHistory hist = mmo.computeStatHistory(itemStat);
if (hist != null) {
hist.registerExternalData(data);
mmo.setStatHistory(itemStat, hist);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static void logStatLine(String phase, LiveMMOItem mmo, String statId, Do
double total = current != null ? current.getValue() : 0;
double og = 0;
double external = 0;
StatHistory hist = StatHistory.from(mmo, itemStat);
StatHistory hist = mmo.computeStatHistory(itemStat);
if (hist != null) {
Object ogData = hist.getOriginalData();
if (ogData instanceof DoubleData doubleOg) {
Expand Down