Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod Material support, for Hybrid Server #7126

Merged
merged 20 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 src/main/java/ch/njol/skript/aliases/Aliases.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ private static void loadMissingAliases() {
for (Material material : Material.values()) {
if (!material.isLegacy() && !provider.hasAliasForMaterial(material)) {
NamespacedKey key = material.getKey();
String name = key.getKey().replace("_", " ");
String name = (key.getNamespace().equals(NamespacedKey.MINECRAFT) ? key.getKey() : key.toString())
.replace("_", " ");
// mod:an_item → mod:an item
sovdeeth marked this conversation as resolved.
Show resolved Hide resolved
// minecraft:dirt → dirt
0XPYEX0 marked this conversation as resolved.
Show resolved Hide resolved
parser.loadAlias(name + "¦s", key.toString());
Skript.debug(ChatColor.YELLOW + "Creating temporary alias for: " + key);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/ch/njol/skript/bukkitutil/BukkitUnsafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.UnsafeValues;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -70,7 +71,10 @@ public class BukkitUnsafe {

@Nullable
public static Material getMaterialFromMinecraftId(String id) {
0XPYEX0 marked this conversation as resolved.
Show resolved Hide resolved
return Material.matchMaterial(id);
return Material.matchMaterial(id.toLowerCase().startsWith(NamespacedKey.MINECRAFT + ":")
? id
: id.replace(":", "_") //For Hybrid Server
);
sovdeeth marked this conversation as resolved.
Show resolved Hide resolved
}

public static void modifyItemStack(ItemStack stack, String arguments) {
Expand Down