diff --git a/.assets/banner.png b/.assets/banner.png
new file mode 100644
index 0000000..22234eb
Binary files /dev/null and b/.assets/banner.png differ
diff --git a/.assets/banner_big.png b/.assets/banner_big.png
new file mode 100644
index 0000000..7168751
Binary files /dev/null and b/.assets/banner_big.png differ
diff --git a/.assets/icon.png b/.assets/icon.png
new file mode 100644
index 0000000..ff5fe45
Binary files /dev/null and b/.assets/icon.png differ
diff --git a/.assets/product_page.png b/.assets/product_page.png
new file mode 100644
index 0000000..2b57919
Binary files /dev/null and b/.assets/product_page.png differ
diff --git a/.assets/screenshots/screen1.png b/.assets/screenshots/screen1.png
new file mode 100644
index 0000000..3d442af
Binary files /dev/null and b/.assets/screenshots/screen1.png differ
diff --git a/.assets/screenshots/screen2.png b/.assets/screenshots/screen2.png
new file mode 100644
index 0000000..3b5d6f6
Binary files /dev/null and b/.assets/screenshots/screen2.png differ
diff --git a/.assets/screenshots/screen3.png b/.assets/screenshots/screen3.png
new file mode 100644
index 0000000..5737734
Binary files /dev/null and b/.assets/screenshots/screen3.png differ
diff --git a/.assets/screenshots/screen4.png b/.assets/screenshots/screen4.png
new file mode 100644
index 0000000..95eba1f
Binary files /dev/null and b/.assets/screenshots/screen4.png differ
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index dfe0770..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-# Auto detect text files and perform LF normalization
-* text=auto
diff --git a/.gitignore b/.gitignore
index 2293b2e..151529c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,9 +111,9 @@ buildNumber.properties
# Common working directory
run/
+
+# My stuff
/.cache/
-/output/
/.paper-nms/
-/custom_mapping.txt
-/.assets/
-target
\ No newline at end of file
+/output/
+
diff --git a/.mvn-exec/CopyFile.bat b/.mvn-exec/CopyFile.bat
deleted file mode 100644
index e37fd65..0000000
--- a/.mvn-exec/CopyFile.bat
+++ /dev/null
@@ -1 +0,0 @@
-echo f | xcopy C:\Progetti\Minecraft\Spigot\VanillaCustomizer\output\VanillaCustomizer.jar C:\Progetti\Minecraft\TestServer\blank_template\1.20\plugins\VanillaCustomizer.jar /Y
diff --git a/VanillaCustomizer-core/pom.xml b/VanillaCustomizer-core/pom.xml
index 05c4892..6a7ccf4 100644
--- a/VanillaCustomizer-core/pom.xml
+++ b/VanillaCustomizer-core/pom.xml
@@ -5,13 +5,14 @@
VanillaCustomizer
dev.lone
- VERSION
+ 1.0
4.0.0
VanillaCustomizer-core
+
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
@@ -25,34 +26,71 @@
https://oss.sonatype.org/content/groups/public
- dmulloy2-repo
- https://repo.dmulloy2.net/repository/public/
+ sonatype
+ https://oss.sonatype.org/content/groups/public/
- matteodev
- https://www.matteodev.it/spigot/public/maven/
+ papermc
+ https://papermc.io/repo/repository/maven-public/
+
+
+ sk89q-repo
+ https://maven.enginehub.org/repo/
+
+
+ codemc
+ https://repo.codemc.org/repository/maven-public/
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
+ net.md-5
+ bungeecord-chat
+ 1.20-R0.2
+ provided
+
+
+ io.papermc.paper
+ paper-api
+ 1.21.1-R0.1-SNAPSHOT
+ provided
+
org.spigotmc
- spigot-api
- 1.19.2-R0.1-SNAPSHOT
+ spigot
+ 1.21.1-R0.1-SNAPSHOT
provided
- dev.lone
+ dev.lone.LoneLibs
LoneLibs
- 1.0.50
+ 1.0
+ system
+ ${jars_libs_folder}/LoneLibs.jar
- com.comphenix.protocol
+ libs
ProtocolLib
- 5.1.0
- provided
+ 1.0
+ system
+ ${jars_libs_folder}/ProtocolLib.jar
+
+ org.jetbrains
+ annotations
+ 24.0.0
+ compile
+
+
+
\ No newline at end of file
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/ChangeSession.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/ChangeSession.java
index 9fc7205..279f1fa 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/ChangeSession.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/ChangeSession.java
@@ -1,8 +1,11 @@
package dev.lone.vanillacustomizer;
import dev.lone.LoneLibs.nbt.nbtapi.NBTItem;
-import dev.lone.LoneLibs.annotations.Nullable;
+import org.jetbrains.annotations.Nullable;
import dev.lone.vanillacustomizer.customization.rules.RuleVanillaItemMatcher;
+import dev.lone.vanillacustomizer.nms.NMS;
+import lonelibs.dev.lone.fastnbt.nms.nbt.NItem;
+import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -10,20 +13,23 @@ import org.bukkit.inventory.meta.ItemMeta;
public class ChangeSession
{
public final ItemStack item;
+ private final Player player;
public final ItemStack originalItem;
public ItemMeta meta;
- public NBTItem nbt;
+ public NBTItem nbtLegacy;
+ public NItem nbt;
public final boolean isVanilla;
@Nullable
private Boolean hasChanged_cached;
- public ChangeSession(ItemStack item, boolean trackChanges)
+ public ChangeSession(ItemStack item, Player player, boolean trackChanges)
{
this.item = item;
+ this.player = player;
if(trackChanges)
this.originalItem = item.clone();
else
@@ -32,6 +38,11 @@ public class ChangeSession
isVanilla = RuleVanillaItemMatcher.satisfy(item);
}
+ public Player getPlayer()
+ {
+ return player;
+ }
+
public ItemMeta refreshMeta()
{
// Meta always needs to be refreshed as Spigot caches it!
@@ -39,16 +50,26 @@ public class ChangeSession
return meta;
}
- private void refreshNbt()
+ private void refreshNBT()
{
- nbt = new NBTItem(item);
+ nbtLegacy = new NBTItem(item);
+ if(NMS.is_v1_1_20_5_or_greater)
+ nbt = new NItem(item);
}
- public NBTItem nbt()
+ public NBTItem nbtLegacy()
+ {
+ if(nbtLegacy != null)
+ return nbtLegacy;
+ refreshNBT();
+ return nbtLegacy;
+ }
+
+ public NItem nbt()
{
if(nbt != null)
return nbt;
- refreshNbt();
+ refreshNBT();
return nbt;
}
@@ -59,12 +80,14 @@ public class ChangeSession
public void saveNbt()
{
// nbt.saveMetaChanges(); // TODO: idk if I need to somehow save the data or not, probably new NBT api lib doesn't require it anymore.
+ if(nbt != null)
+ nbt.save();
}
public void applyMeta()
{
this.item.setItemMeta(this.meta);
- refreshNbt();
+ refreshNBT();
}
public boolean hasChanged()
@@ -80,7 +103,7 @@ public class ChangeSession
public void refreshAll()
{
- refreshNbt();
+ refreshNBT();
refreshMeta();
}
}
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Customizations.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Customizations.java
index 46ac7a6..9e8f28e 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Customizations.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Customizations.java
@@ -2,7 +2,8 @@ package dev.lone.vanillacustomizer;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import dev.lone.LoneLibs.annotations.Nullable;
+import dev.lone.vanillacustomizer.exception.InvalidCustomizationPropertyException;
+import org.jetbrains.annotations.Nullable;
import dev.lone.vanillacustomizer.api.VanillaCustomizerApi;
import dev.lone.vanillacustomizer.commands.registered.MainCommand;
import dev.lone.vanillacustomizer.customization.changes.*;
@@ -39,13 +40,21 @@ public class Customizations
{
ConfigFile config = new ConfigFile(Main.inst(), false, file.toPath().toString(), false, false);
- ConfigurationSection cosmeticsSection = config.getConfigurationSection("customizations");
- if (cosmeticsSection == null) // File has no rules
+ boolean ignoreInventoriesEnabled = config.getBoolean("settings.ignore_inventories.enabled");
+ boolean ignoreAnyCustomInventory = ignoreInventoriesEnabled && config.getBoolean("settings.ignore_inventories.any_custom", false);
+ List ignoreInventoriesByTitle = ignoreInventoriesEnabled ? config.getStringList("settings.ignore_inventories.by_title"): null;
+
+ ConfigurationSection customizationsSection = config.getConfigurationSection("customizations");
+ if (customizationsSection == null) // File has no rules
continue;
- for (String key : cosmeticsSection.getKeys(false))
+ for (String key : customizationsSection.getKeys(false))
{
- Customization customization = new Customization();
+ Customization customization = new Customization(
+ ignoreInventoriesEnabled,
+ ignoreAnyCustomInventory,
+ ignoreInventoriesByTitle
+ );
ConfigurationSection section = config.getConfigurationSection("customizations." + key);
assert section != null;
@@ -169,7 +178,7 @@ public class Customizations
}
catch (Throwable ex)
{
- if(ex instanceof InvalidCustomizationPropertyExtension)
+ if(ex instanceof InvalidCustomizationPropertyException)
{
Main.msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath());
Main.msg.error(ex.getMessage());
@@ -282,10 +291,10 @@ public class Customizations
}
else if (tmp.length == 2)
{
- if (Utilz.isNumeric(tmp[1]))
+ if (Utils.isNumeric(tmp[1]))
{
enchant = Enchantment.getByName(tmp[0]);
- enchantLevel = Utilz.parseInt(tmp[1], 1);
+ enchantLevel = Utils.parseInt(tmp[1], 1);
if (enchant == null)
enchant = Enchantment.getByKey(NamespacedKey.minecraft(tmp[0]));
@@ -298,7 +307,7 @@ public class Customizations
else if (tmp.length == 3)
{
enchant = Enchantment.getByKey(new NamespacedKey(tmp[0], tmp[1]));
- enchantLevel = Utilz.parseInt(tmp[2], 1);
+ enchantLevel = Utils.parseInt(tmp[2], 1);
}
enchants.put(enchant, enchantLevel);
@@ -324,7 +333,7 @@ public class Customizations
}
else if (tmp.length == 2)
{
- if (Utilz.isNumeric(tmp[1]))
+ if (Utils.isNumeric(tmp[1]))
{
enchant = Enchantment.getByName(tmp[0]);
if (enchant == null)
@@ -360,11 +369,11 @@ public class Customizations
throwInvalidConfig();
@Nullable String attributeStr = getStringOrThrow(attributeSection, "attribute");
- Attribute attribute = Utilz.strToAttributeType(attributeStr);
+ Attribute attribute = Utils.strToAttributeType(attributeStr);
if (attribute == null)
throwInvalidPropertyValue("attribute");
@Nullable String slotStr = getStringOrThrow(attributeSection, "slot");
- EquipmentSlot slot = Utilz.strToVanillaEquipmentSlot(slotStr);
+ EquipmentSlot slot = Utils.strToVanillaEquipmentSlot(slotStr);
if (slot == null)
throwInvalidPropertyValue("slot");
@@ -422,7 +431,7 @@ public class Customizations
}
catch (Throwable ex)
{
- if(ex instanceof InvalidCustomizationPropertyExtension)
+ if(ex instanceof InvalidCustomizationPropertyException)
{
Main.msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath());
Main.msg.error(ex.getMessage());
@@ -451,22 +460,22 @@ public class Customizations
private void throwInvalidConfig()
{
- throw new InvalidCustomizationPropertyExtension("Invalid configuration. Please check the tutorials.");
+ throw new InvalidCustomizationPropertyException("Invalid configuration. Please check the tutorials.");
}
private void throwMissingProperty(String name)
{
- throw new InvalidCustomizationPropertyExtension("Missing property '" + name + "'.");
+ throw new InvalidCustomizationPropertyException("Missing property '" + name + "'.");
}
private void throwInvalidPropertyValue(String name)
{
- throw new InvalidCustomizationPropertyExtension("Invalid value for property '" + name + "'.");
+ throw new InvalidCustomizationPropertyException("Invalid value for property '" + name + "'.");
}
private void throwInvalidPropertyValue(String name, String value)
{
- throw new InvalidCustomizationPropertyExtension("Invalid value for property '" + name + "' -> '" + value + "'.");
+ throw new InvalidCustomizationPropertyException("Invalid value for property '" + name + "' -> '" + value + "'.");
}
public void handle(ItemStack itemStack, Player player)
@@ -475,7 +484,7 @@ public class Customizations
return;
boolean trackChanges = MainCommand.hasDebugTag(player);
- ChangeSession session = new ChangeSession(itemStack, trackChanges);
+ ChangeSession session = new ChangeSession(itemStack, player, trackChanges);
for (Map.Entry entry : customizations.entrySet())
{
Customization customization = entry.getValue();
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/InvalidCustomizationPropertyExtension.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/InvalidCustomizationPropertyExtension.java
deleted file mode 100644
index b2a2e7b..0000000
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/InvalidCustomizationPropertyExtension.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package dev.lone.vanillacustomizer;
-
-public class InvalidCustomizationPropertyExtension extends IllegalArgumentException
-{
- public InvalidCustomizationPropertyExtension(String text)
- {
- super(text);
- }
-}
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Main.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Main.java
index f01a5e1..e779062 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Main.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/Main.java
@@ -27,6 +27,7 @@ public final class Main extends JavaPlugin implements Listener
// https://game8.co/games/Minecraft/archives/378457#hl_1
//DO NOT SET AS "final" OR SPIGOT.MC won't replace it.
+ @SuppressWarnings("unused")
public static String b = "%%__USER__%%";
public static Msg msg;
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/CommandRun.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/CommandRun.java
index 67309d4..70d9549 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/CommandRun.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/CommandRun.java
@@ -1,6 +1,6 @@
package dev.lone.vanillacustomizer.commands;
-import dev.lone.LoneLibs.annotations.NotNull;
+import org.jetbrains.annotations.NotNull;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/registered/MainCommand.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/registered/MainCommand.java
index 14581d6..68df565 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/registered/MainCommand.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/commands/registered/MainCommand.java
@@ -1,10 +1,10 @@
package dev.lone.vanillacustomizer.commands.registered;
-import dev.lone.LoneLibs.annotations.NotNull;
import dev.lone.vanillacustomizer.Main;
import dev.lone.vanillacustomizer.commands.CommandRun;
import dev.lone.vanillacustomizer.utils.SmallCaps;
import fr.mrmicky.fastinv.FastInv;
+import org.jetbrains.annotations.NotNull;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
@@ -58,7 +58,11 @@ public class MainCommand extends CommandRun
break;
case "small":
-
+ if(args.length < 2)
+ {
+ Main.msg.send(player, "Usage: /vanillacustomizer small ");
+ return;
+ }
String text = args[1];
Main.msg.send(player, SmallCaps.apply(text));
break;
@@ -130,6 +134,8 @@ public class MainCommand extends CommandRun
@Override
public List onTabComplete(@NotNull CommandSender sender, Command command, @NotNull String alias, @NotNull String[] args)
{
- return List.of("reload", "showdebugtag", "small", "debugmenu");
+ if(args.length == 1)
+ return List.of("reload", "showdebugtag", "small", "debugmenu");
+ return List.of();
}
}
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/Customization.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/Customization.java
index c347e1f..127a550 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/Customization.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/Customization.java
@@ -3,16 +3,29 @@ package dev.lone.vanillacustomizer.customization;
import dev.lone.vanillacustomizer.ChangeSession;
import dev.lone.vanillacustomizer.customization.changes.IChange;
import dev.lone.vanillacustomizer.customization.rules.IRule;
-import org.bukkit.inventory.ItemStack;
+import dev.lone.vanillacustomizer.utils.Utils;
+import org.apache.commons.io.FilenameUtils;
+import org.bukkit.inventory.InventoryView;
import java.util.ArrayList;
import java.util.List;
public class Customization
{
+ public final boolean ignoreInventoriesEnabled;
+ public final boolean ignoreAnyCustomInventory;
+ public final List ignoreInventoriesByTitle;
+
public List rules = new ArrayList<>();
public List changes = new ArrayList<>();
+ public Customization(boolean ignoreInventoriesEnabled, boolean ignoreAnyCustomInventory, List ignoreInventoriesByTitle)
+ {
+ this.ignoreAnyCustomInventory = ignoreAnyCustomInventory;
+ this.ignoreInventoriesByTitle = ignoreInventoriesByTitle;
+ this.ignoreInventoriesEnabled = ignoreInventoriesEnabled;
+ }
+
public boolean isEmpty()
{
return rules.isEmpty() && changes.isEmpty();
@@ -28,8 +41,24 @@ public class Customization
changes.add(change);
}
- public boolean matchesAll(ChangeSession session)
+ boolean matchesAll(ChangeSession session)
{
+ InventoryView openInventory = session.getPlayer().getOpenInventory();
+ if(ignoreInventoriesEnabled)
+ {
+ if(ignoreAnyCustomInventory)
+ {
+ if(Utils.isCustomInventory(openInventory))
+ return false;
+ }
+
+ for (String wildcard : ignoreInventoriesByTitle)
+ {
+ if (FilenameUtils.wildcardMatch(openInventory.getTitle(), wildcard))
+ return false;
+ }
+ }
+
for (IRule rule : rules)
{
if(!rule.matches(session))
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesAdd.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesAdd.java
index 24ef2a1..59dcecf 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesAdd.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesAdd.java
@@ -6,8 +6,8 @@ import dev.lone.vanillacustomizer.ChangeSession;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.inventory.EquipmentSlot;
-import dev.lone.LoneLibs.annotations.NotNull;
-import dev.lone.LoneLibs.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.UUID;
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesRemove.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesRemove.java
index f58777f..5517c7e 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesRemove.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/AttributesRemove.java
@@ -6,12 +6,12 @@ import dev.lone.vanillacustomizer.ChangeSession;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.inventory.EquipmentSlot;
-import dev.lone.LoneLibs.annotations.NotNull;
-import dev.lone.LoneLibs.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.UUID;
-@Deprecated //TODO
+@Deprecated //TODO implement this shit
public class AttributesRemove implements IChange
{
Multimap modifiers;
diff --git a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/LoreInsert.java b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/LoreInsert.java
index d45a963..47835d9 100644
--- a/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/LoreInsert.java
+++ b/VanillaCustomizer-core/src/main/java/dev/lone/vanillacustomizer/customization/changes/LoreInsert.java
@@ -5,8 +5,12 @@ import dev.lone.LoneLibs.nbt.nbtapi.NBTItem;
import dev.lone.LoneLibs.nbt.nbtapi.NBTList;
import dev.lone.vanillacustomizer.ChangeSession;
import dev.lone.LoneLibs.chat.Comp;
+import dev.lone.vanillacustomizer.nms.NMS;
import dev.lone.vanillacustomizer.utils.ConfigFile;
+import dev.lone.vanillacustomizer.utils.Utils;
+import lonelibs.dev.lone.fastnbt.nms.nbt.NItem;
+import java.util.ArrayList;
import java.util.List;
public class LoreInsert implements IChange
@@ -23,10 +27,44 @@ public class LoreInsert implements IChange
@Override
public void apply(ChangeSession session)
{
- NBTItem nbt = session.nbt();
+ if(NMS.is_v1_1_20_5_or_greater)
+ {
+ NItem nbt = session.nbt();
+ List