Skip to content

Commit

Permalink
Merge branch 'master' into dev/update
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBedrock committed Sep 22, 2024
2 parents 0f51bd9 + 06d1487 commit 328c9aa
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 58 deletions.
20 changes: 11 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import kotlin.io.path.listDirectoryEntries
plugins {
id("java")
//id("com.github.johnrengelman.shadow") version "8.1.1"
id("xyz.jpenilla.run-paper") version "2.2.4"
id("xyz.jpenilla.run-paper") version "2.3.1"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // Generates plugin.yml
id("io.papermc.paperweight.userdev") version "1.7.1" apply false
id("io.papermc.paperweight.userdev") version "1.7.2" apply false
id("io.github.goooler.shadow") version "8.1.8"
alias(libs.plugins.mia.publication)
}

class NMSVersion(val nmsVersion: String, val serverVersion: String)
infix fun String.toNms(that: String): NMSVersion = NMSVersion(this, that)
val SUPPORTED_VERSIONS: List<NMSVersion> = listOf(
"v1_18_R1" toNms "1.18.1-R0.1-SNAPSHOT",
"v1_18_R2" toNms "1.18.2-R0.1-SNAPSHOT",
"v1_19_R1" toNms "1.19.2-R0.1-SNAPSHOT",
"v1_19_R2" toNms "1.19.3-R0.1-SNAPSHOT",
"v1_19_R3" toNms "1.19.4-R0.1-SNAPSHOT",
//"v1_18_R1" toNms "1.18.1-R0.1-SNAPSHOT",
//"v1_18_R2" toNms "1.18.2-R0.1-SNAPSHOT",
//"v1_19_R1" toNms "1.19.2-R0.1-SNAPSHOT",
//"v1_19_R2" toNms "1.19.3-R0.1-SNAPSHOT",
//"v1_19_R3" toNms "1.19.4-R0.1-SNAPSHOT",
"v1_20_R1" toNms "1.20.1-R0.1-SNAPSHOT",
"v1_20_R2" toNms "1.20.2-R0.1-SNAPSHOT",
"v1_20_R3" toNms "1.20.4-R0.1-SNAPSHOT",
Expand All @@ -37,7 +37,7 @@ val spigotPluginPath = project.findProperty("oraxen_spigot_plugin_path")?.toStri
val pluginVersion: String by project
val commandApiVersion = "9.5.3"
val adventureVersion = "4.17.0"
val platformVersion = "4.3.3"
val platformVersion = "4.3.4"
val googleGsonVersion = "2.10.1"
val apacheLang3Version = "3.14.0"
group = "io.th0rgal"
Expand Down Expand Up @@ -104,7 +104,7 @@ allprojects {
implementation("team.unnamed:creative-api:1.7.3") { exclude("net.kyori") }
implementation("dev.jorel:commandapi-bukkit-shade:$commandApiVersion")
implementation("org.bstats:bstats-bukkit:3.0.0")
implementation("io.th0rgal:protectionlib:1.6.0")
implementation("io.th0rgal:protectionlib:1.6.1")
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.12")
implementation("com.jeff-media:custom-block-data:2.2.2")
implementation("com.jeff-media:MorePersistentDataTypes:2.4.0")
Expand All @@ -121,6 +121,8 @@ dependencies {
SUPPORTED_VERSIONS.forEach { implementation(project(path = ":${it.nmsVersion}", configuration = "reobf")) }
}



java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ private CommandAPICommand getTakeCommand() {
} else {
int toRemove = amount.get();
while (toRemove > 0) {
for (ItemStack itemStack : target.getInventory().getContents()) {
ItemStack[] items = target.getInventory().getStorageContents();
for (int i = 0; i < items.length; i++) {
ItemStack itemStack = items[i];
if (!ItemUtils.isEmpty(itemStack) && itemID.equals(OraxenItems.getIdByItem(itemStack))) {
if (itemStack.getAmount() <= toRemove) {
toRemove -= itemStack.getAmount();
target.getInventory().remove(itemStack);
target.getInventory().clear(i);
} else {
itemStack.setAmount(itemStack.getAmount() - toRemove);
toRemove = 0;
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/io/th0rgal/oraxen/items/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,7 @@ public ItemBuilder setBasePotionType(final PotionType potionType) {
}

public ItemBuilder addPotionEffect(final PotionEffect potionEffect) {
if (potionEffects == null)
potionEffects = new ArrayList<>();
if (potionEffects == null) potionEffects = new ArrayList<>();
potionEffects.add(potionEffect);
return this;
}
Expand Down Expand Up @@ -478,7 +477,7 @@ public boolean hasCustomTag() {


public <T, Z> void addCustomTag(NamespacedKey key, PersistentDataType<T, Z> type, Z value) {
persistentDataContainer.set(key, type, value);
persistentDataMap.put(new PersistentDataSpace(key, type), value);
}

public ItemBuilder removeCustomTag(NamespacedKey key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ItemTemplate {
private static final Map<String, ItemParser> itemTemplates = new HashMap<>();

public ItemTemplate(ConfigurationSection section) {
section.set("injectID", false);
section.set("injectId", false);
itemTemplates.put(section.getName(), new ItemParser(section));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,16 @@ public Entity place(Location location, ItemStack originalItem, Float yaw, BlockF
return baseEntity;
}

private boolean allowWallForLimitedFloor(Location location, BlockFace blockFace) {
return blockFace.getModY() == 0 && location.getBlock().getRelative(BlockFace.DOWN).isSolid();
}

private Location correctedSpawnLocation(Location baseLocation, BlockFace facing) {
boolean isWall = hasLimitedPlacing() && limitedPlacing.isWall();
boolean isRoof = hasLimitedPlacing() && limitedPlacing.isRoof();
boolean isFixed = hasDisplayEntityProperties() && displayEntityProperties.getDisplayTransform() == ItemDisplay.ItemDisplayTransform.FIXED;
Location correctedLocation = isFixed && facing == BlockFace.UP ? BlockHelpers.toCenterBlockLocation(baseLocation) : BlockHelpers.toCenterLocation(baseLocation);
Location correctedLocation = isFixed && (facing == BlockFace.UP || allowWallForLimitedFloor(baseLocation, facing))
? BlockHelpers.toCenterBlockLocation(baseLocation) : BlockHelpers.toCenterLocation(baseLocation);

if (furnitureType != FurnitureType.DISPLAY_ENTITY || !hasDisplayEntityProperties()) return correctedLocation;
if (displayEntityProperties.getDisplayTransform() != ItemDisplay.ItemDisplayTransform.NONE && !isWall && !isRoof) return correctedLocation;
Expand Down Expand Up @@ -505,12 +510,11 @@ private void setItemDisplayData(ItemDisplay itemDisplay, ItemStack item, Float y
float pitch;
if (VersionUtil.atOrAbove("1.20.1")) {
if (hasLimitedPlacing() && isFixed) {
if (limitedPlacing.isFloor() && facing == BlockFace.UP) pitch = -90;
if (limitedPlacing.isFloor() && (facing == BlockFace.UP || allowWallForLimitedFloor(itemDisplay.getLocation(), facing))) pitch = -90;
else if (limitedPlacing.isRoof() && facing == BlockFace.DOWN) pitch = 90;
else pitch = 0;

if (limitedPlacing.isRoof() && facing == BlockFace.DOWN)
yaw -= 180;
if (limitedPlacing.isRoof() && facing == BlockFace.DOWN) yaw -= 180;
else if (limitedPlacing.isWall() && facing.getModY() == 0) yaw = 90f * facing.ordinal() - 180;
} else pitch = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/io/th0rgal/oraxen/nms/NMSHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import io.th0rgal.oraxen.OraxenPlugin;
import io.th0rgal.oraxen.config.Settings;
import io.th0rgal.oraxen.utils.VersionUtil;
import io.th0rgal.oraxen.utils.logs.Logs;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -43,6 +44,7 @@ public static void setup() {
IllegalAccessException | NoSuchMethodException e) {
Logs.logWarning("Oraxen does not support this version of Minecraft (" + version + ") yet.");
Logs.logWarning("NMS features will be disabled...");
if (Settings.DEBUG.toBool()) e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.JsonObject;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.config.Settings;
import io.th0rgal.oraxen.utils.Utils;
import io.th0rgal.oraxen.utils.VirtualFile;
import io.th0rgal.oraxen.utils.logs.Logs;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -20,14 +19,37 @@ public class AtlasGenerator {
public AtlasGenerator() {
}

private static class TexturePath {
public final String namespace;
public final String path;

public TexturePath(String namespace, String path) {
this.namespace = namespace;
this.path = path.replace(".png", "");
}

public TexturePath(String path) {
this.namespace = path.contains(":") ? StringUtils.substringBefore(path, ":") : "minecraft";
this.path = (path.contains(":") ? path.split(":")[1] : path).replace(".png", "");
}

public String toPath() {
return namespace + ":" + path;
}

public boolean in(Collection<TexturePath> texturePaths) {
return texturePaths.stream().anyMatch(texturePath -> namespace.equals(texturePath.namespace) && path.equals(texturePath.path));
}
}

public static void generateAtlasFile(List<VirtualFile> output, Set<String> malformedTextures) {
Logs.logSuccess("Generating atlas-file for 1.19.3+ Resource Pack format");
if (Settings.EXCLUDE_MALFORMED_ATLAS.toBool() && !malformedTextures.isEmpty())
Logs.logWarning("Attempting to exclude malformed textures from atlas-file");

JsonObject atlas = new JsonObject();
JsonArray atlasContent = new JsonArray();
LinkedHashMap<VirtualFile, String> textureSubFolders = new LinkedHashMap<>();
LinkedHashMap<VirtualFile, TexturePath> textureSubFolders = new LinkedHashMap<>();
for (VirtualFile v : output.stream().filter(v ->
v.getPath().split("/").length > 3
&& v.getPath().split("/")[2].equals("textures")
Expand All @@ -37,52 +59,49 @@ public static void generateAtlasFile(List<VirtualFile> output, Set<String> malfo
&& PackSlicer.INPUTS.stream().noneMatch(input -> v.getPath().endsWith(input.path))
&& PackSlicer.OUTPUT_PATHS.stream().noneMatch(outPath -> v.getPath().endsWith(outPath))
).sorted().collect(Collectors.toCollection(LinkedHashSet::new))) {
textureSubFolders.put(v, Utils.removeExtensionOnly(v.getPath().replaceFirst("assets/.*/textures/", "")));
textureSubFolders.put(v, new TexturePath(StringUtils.substringBetween(v.getPath(), "assets/", "/textures"), StringUtils.substringAfter(v.getPath(), "textures/")));
}

Set<String> itemTextures = new HashSet<>();
Set<TexturePath> itemTextures = new HashSet<>();
OraxenItems.getItems().stream().filter(builder -> builder.hasOraxenMeta() && builder.getOraxenMeta().hasLayers())
.forEach(builder -> itemTextures.addAll(builder.getOraxenMeta().getLayers()));
.forEach(builder -> itemTextures.addAll(builder.getOraxenMeta().getLayers().stream().map(TexturePath::new).toList()));

Set<String> fontTextures = new LinkedHashSet<>();
Set<TexturePath> fontTextures = new LinkedHashSet<>();
Set<JsonObject> fonts = output.stream().filter(v -> v.getPath().matches("assets/.*/font/.*.json") && v.isJsonObject()).map(VirtualFile::toJsonObject).collect(Collectors.toSet());
for (JsonObject font : fonts) {
if (font == null || !font.has("providers")) continue;
for (JsonElement providerElement : font.getAsJsonArray("providers")) {
if (!providerElement.isJsonObject()) continue;
JsonObject provider = providerElement.getAsJsonObject();
if (provider.has("file")) {
fontTextures.add(provider.get("file").getAsString().replace(".png", ""));
fontTextures.add(new TexturePath(provider.get("file").getAsString()));
}
}
}

for (Map.Entry<VirtualFile, String> entry : textureSubFolders.entrySet()) {
VirtualFile virtual = entry.getKey();
String path = entry.getValue();
for (Map.Entry<VirtualFile, TexturePath> entry : textureSubFolders.entrySet()) {
TexturePath texturePath = entry.getValue();

// If a texture is for a font, do not add it to atlas, unless an item uses it
// Default example is required/exit_icon.png
if (fontTextures.contains(path) && !itemTextures.contains(path)) continue;
if (texturePath.in(fontTextures) && !texturePath.in(itemTextures)) continue;

JsonObject atlasEntry = new JsonObject();
String namespace = virtual.getPath().replaceFirst("assets/", "").split("/")[0];
String malformPathCheck = "assets/" + namespace + "/textures/" + path + ".png";
String malformPathCheck = "assets/" + texturePath.namespace + "/textures/" + texturePath.path + ".png";
if (Settings.EXCLUDE_MALFORMED_ATLAS.toBool() && malformedTextures.stream().anyMatch(malformPathCheck::startsWith)) {
Logs.logWarning("Excluding malformed texture from atlas-file: <gold>" + malformPathCheck);
continue;
}

if (Settings.ATLAS_GENERATION_TYPE.toString().equals("DIRECTORY")) {
path = StringUtils.substringBeforeLast(path, "/");
String path = StringUtils.substringBeforeLast(texturePath.path, "/");
atlasEntry.addProperty("type", "directory");
atlasEntry.addProperty("source", path);
atlasEntry.addProperty("prefix", path + "/");
} else {
String sprite = namespace + ":" + path;
atlasEntry.addProperty("type", "single");
atlasEntry.addProperty("resource", sprite);
atlasEntry.addProperty("sprite", sprite);
atlasEntry.addProperty("resource", texturePath.toPath());
atlasEntry.addProperty("sprite", texturePath.toPath());
}

if (!atlasContent.contains(atlasEntry))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public String getVanillaTextureName(final Material material, final boolean model
String materialName = material.toString().toLowerCase(Locale.ROOT);
if (!model) {
if (material == Material.COMPASS) return "item/compass_16";
if (VersionUtil.atOrAbove("1.19") && material == Material.RECOVERY_COMPASS) return "item/recovery_compass_16";
if (material == Material.DEBUG_STICK) return "item/stick";
if (material == Material.ENCHANTED_GOLDEN_APPLE) return "item/golden_apple";
if (material == Material.SUNFLOWER) return "block/sunflower_front";
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pluginVersion=1.181.0
pluginVersion=1.182.0
idofrontVersion=0.21.12
10 changes: 5 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ dependencyResolutionManagement {

include(
"core",
"v1_18_R1",
"v1_18_R2",
"v1_19_R1",
"v1_19_R2",
"v1_19_R3",
//"v1_18_R1",
//"v1_18_R2",
//"v1_19_R1",
//"v1_19_R2",
//"v1_19_R3",
"v1_20_R1",
"v1_20_R2",
"v1_20_R3",
Expand Down
4 changes: 2 additions & 2 deletions v1_18_R1/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand All @@ -21,5 +21,5 @@ tasks {
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
4 changes: 2 additions & 2 deletions v1_18_R2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand All @@ -21,5 +21,5 @@ tasks {
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
4 changes: 2 additions & 2 deletions v1_19_R1/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand All @@ -21,5 +21,5 @@ tasks {
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
4 changes: 2 additions & 2 deletions v1_19_R2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand All @@ -21,5 +21,5 @@ tasks {
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
2 changes: 1 addition & 1 deletion v1_19_R3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand Down
2 changes: 1 addition & 1 deletion v1_20_R1/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand Down
2 changes: 1 addition & 1 deletion v1_20_R2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand Down
2 changes: 1 addition & 1 deletion v1_20_R3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.papermc.paperweight.userdev") version "1.7.2"
id("io.github.goooler.shadow") version "8.1.8"
}

Expand Down
Loading

0 comments on commit 328c9aa

Please sign in to comment.