Skip to content
Open
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
113 changes: 100 additions & 13 deletions VanillaCustomizer-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,50 @@

<artifactId>VanillaCustomizer-core</artifactId>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>beer.devs.fastnbt.</pattern>
<shadedPattern>dev.lone.vanillacustomizer.libs.beer.devs.fastnbt.</shadedPattern>
</relocation>
<relocation>
<pattern>fr.mrmicky.fastinv</pattern>
<shadedPattern>dev.lone.vanillacustomizer.libs.fr.mrmicky.fastinv</shadedPattern>
</relocation>
<relocation>
<pattern>de.tr7zw.changeme.nbtapi</pattern>
<shadedPattern>dev.lone.vanillacustomizer.libs.de.tr7zw.changeme.nbtapi</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
Expand Down Expand Up @@ -49,34 +93,32 @@


<dependencies>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>2.4.2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.20-R0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<artifactId>spigot-api</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>dev.lone.LoneLibs</groupId>
<artifactId>LoneLibs</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${jars_libs_folder}/LoneLibs.jar</systemPath>
<groupId>beer.devs</groupId>
<artifactId>FastNbt-jar</artifactId>
<version>1.4.15</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>libs</groupId>
<artifactId>ProtocolLib</artifactId>
Expand All @@ -90,6 +132,51 @@
<version>24.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ca.bkaw</groupId>
<artifactId>paper-nms</artifactId>
<version>1.21.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>fr.mrmicky</groupId>
<artifactId>fastinv</artifactId>
<version>3.1.2</version>
</dependency>

<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.15.5</version>
</dependency>

<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.26.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.26.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.26.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.26.1</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package dev.lone.vanillacustomizer;

import dev.lone.LoneLibs.nbt.nbtapi.NBTItem;
import org.jetbrains.annotations.Nullable;
import beer.devs.fastnbt.nms.nbt.NItem;
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;
import org.jetbrains.annotations.Nullable;

// TODO: find a better name for this
public class ChangeSession
Expand All @@ -18,7 +16,6 @@ public class ChangeSession

public ItemMeta meta;

public NBTItem nbtLegacy;
public NItem nbt;

public final boolean isVanilla;
Expand Down Expand Up @@ -52,17 +49,7 @@ public ItemMeta refreshMeta()

private void refreshNBT()
{
nbtLegacy = new NBTItem(item);
if(NMS.is_v1_1_20_5_or_greater)
nbt = new NItem(item);
}

public NBTItem nbtLegacy()
{
if(nbtLegacy != null)
return nbtLegacy;
refreshNBT();
return nbtLegacy;
nbt = new NItem(item);
}

public NItem nbt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
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.*;
import dev.lone.vanillacustomizer.customization.Customization;
import dev.lone.vanillacustomizer.customization.changes.*;
import dev.lone.vanillacustomizer.customization.matchers.RuleNbtMatcher;
import dev.lone.vanillacustomizer.customization.rules.*;
import dev.lone.vanillacustomizer.exception.InvalidCustomizationPropertyException;
import dev.lone.vanillacustomizer.nms.items.Rarity;
import dev.lone.vanillacustomizer.utils.*;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.apache.commons.io.FileUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute;
Expand All @@ -24,6 +26,7 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -65,7 +68,7 @@ public void load()
ConfigurationSection rulesSection = section.getConfigurationSection("rules");
if (rulesSection == null)
{
Main.msg.error("Error: Customization '" + key + "' missing 'rules'. File: " + config.getPartialFilePath());
Msg.error("Error: Customization '" + key + "' missing 'rules'. File: " + config.getPartialFilePath());
continue;
}

Expand All @@ -81,7 +84,7 @@ public void load()
RuleMaterialWildcards rule = new RuleMaterialWildcards();
for (String noMatch : rule.init(materialWildcards))
{
Main.msg.warn("Warning: 'material_wildcards' -> '" + noMatch + "' of '" + key + "' has matched 0 items. File: " + config.getPartialFilePath());
Msg.warn("Warning: 'material_wildcards' -> '" + noMatch + "' of '" + key + "' has matched 0 items. File: " + config.getPartialFilePath());
}
customization.addRule(rule);
}
Expand All @@ -92,7 +95,7 @@ public void load()
if (material == null)
{
throwInvalidPropertyValue("material", matStr);
// Main.msg.error("Error: Customization '" + key + "' has invalid 'material'. File: " + config.getPartialFilePath());
// Msg.error("Error: Customization '" + key + "' has invalid 'material'. File: " + config.getPartialFilePath());
break;
}

Expand All @@ -108,7 +111,7 @@ public void load()
if (material == null)
{
throwInvalidPropertyValue("material", matStr);
// Main.msg.error("Error: Customization '" + key + "' has invalid 'material'. File: " + config.getPartialFilePath());
// Msg.error("Error: Customization '" + key + "' has invalid 'material'. File: " + config.getPartialFilePath());
}
else
{
Expand Down Expand Up @@ -180,18 +183,18 @@ public void load()
{
if(ex instanceof InvalidCustomizationPropertyException)
{
Main.msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath());
Main.msg.error(ex.getMessage());
Msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath());
Msg.error(ex.getMessage());
}
else
Main.msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath(), ex);
Msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath(), ex);
}
}

ConfigurationSection changesSection = section.getConfigurationSection("changes");
if (changesSection == null)
{
Main.msg.error("Error: Customization '" + key + "' missing 'changes'. File: " + config.getPartialFilePath());
Msg.error("Error: Customization '" + key + "' missing 'changes'. File: " + config.getPartialFilePath());
continue;
}

Expand Down Expand Up @@ -433,11 +436,11 @@ else if (tmp.length == 3)
{
if(ex instanceof InvalidCustomizationPropertyException)
{
Main.msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath());
Main.msg.error(ex.getMessage());
Msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath());
Msg.error(ex.getMessage());
}
else
Main.msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath(), ex);
Msg.error("Error loading customization '" + key + "'. File: " + config.getPartialFilePath(), ex);
}
}

Expand Down Expand Up @@ -480,7 +483,7 @@ private void throwInvalidPropertyValue(String name, String value)

public void handle(ItemStack itemStack, Player player)
{
if (itemStack == null || itemStack.getType() == Material.AIR)
if (itemStack == null || itemStack.getType() == Material.AIR || player.getGameMode() == GameMode.CREATIVE)
return;

boolean trackChanges = MainCommand.hasDebugTag(player);
Expand All @@ -501,9 +504,9 @@ public void handle(ItemStack itemStack, Player player)
if(trackChanges && session.hasChanged())
{
// TODO make it configurable
LoreInsert.putLine(session, 0, ChatColor.GOLD + SmallCaps.apply("VANILLACUSTOMIZER"));
LoreInsert.putLine(session, 0, LegacyComponentSerializer.legacySection().serialize(Component.text(SmallCaps.apply("VANILLACUSTOMIZER")).color(TextColor.color(0xFFAA00))));
//noinspection DataFlowIssue
if(session.refreshMeta().getLore().size() > 1)
if(session.refreshMeta().getPersistentDataContainer().getKeys().size() > 1)
LoreInsert.putLine(session, 1, " ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.Pair;
import dev.lone.LoneLibs.chat.Msg;
import de.tr7zw.changeme.nbtapi.NBT;
import dev.lone.vanillacustomizer.commands.Commands;
import dev.lone.vanillacustomizer.nms.items.ItemsNms;
import dev.lone.vanillacustomizer.utils.Packets;
Expand All @@ -18,6 +18,7 @@
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.plugin.java.JavaPlugin;

import javax.sound.midi.Receiver;
import java.util.List;

public final class Main extends JavaPlugin implements Listener
Expand All @@ -29,7 +30,7 @@ public final class Main extends JavaPlugin implements Listener
//DO NOT SET AS "final" OR SPIGOT.MC won't replace it.
@SuppressWarnings("unused")
public static String b = "%%__USER__%%";
public static Msg msg;
public static Receiver msg;

private static Main inst;

Expand All @@ -45,7 +46,11 @@ public void onEnable()
{
inst = this;

msg = new Msg("[VanillaCustomizer] ");
if (!NBT.preloadApi()) {
getLogger().warning("NBT-API wasn't initialized properly, disabling the plugin");
getPluginLoader().disablePlugin(this);
return;
}

Bukkit.getPluginManager().registerEvents(this, this);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.lone.vanillacustomizer.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.SOURCE)
public @interface Expensive
{
boolean singleCall() default true;

boolean calledInLoop() default true;

boolean calledInLambda() default true;
}
Loading