Prepare for 1.20.6

This commit is contained in:
Telesphoreo 2024-06-14 20:21:56 -05:00
parent f8d45da1ae
commit 21c12f7673
27 changed files with 35 additions and 1361 deletions

View File

@ -2,14 +2,14 @@ import xyz.jpenilla.runpaper.task.RunServer
plugins { plugins {
id("java") id("java")
id("com.github.johnrengelman.shadow") version "8.1.1" id("io.github.goooler.shadow") version "8.1.7"
id("io.papermc.paperweight.userdev") version "1.5.11" id("io.papermc.paperweight.userdev") version "1.7.1"
id("xyz.jpenilla.run-paper") version "2.2.2" id("xyz.jpenilla.run-paper") version "2.3.0"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0" id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
} }
group = "dev.plex" group = "dev.plex"
version = "2.2.1" version = "2.3"
allprojects { allprojects {
repositories { repositories {
@ -30,7 +30,7 @@ allprojects {
subprojects { subprojects {
apply(plugin = "java") apply(plugin = "java")
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "io.github.goooler.shadow")
apply(plugin = "io.papermc.paperweight.userdev") apply(plugin = "io.papermc.paperweight.userdev")
dependencies { dependencies {
@ -47,7 +47,7 @@ subprojects {
} }
java { java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17)) toolchain.languageVersion.set(JavaLanguageVersion.of(21))
} }
bukkit { bukkit {
@ -56,7 +56,7 @@ bukkit {
description = "A new way to edit your items" description = "A new way to edit your items"
authors = listOf("Focusvity", "Telesphoreo") authors = listOf("Focusvity", "Telesphoreo")
main = "dev.plex.itemizerx.ItemizerX" main = "dev.plex.itemizerx.ItemizerX"
apiVersion = "1.17" apiVersion = "1.19"
foliaSupported = true foliaSupported = true
softDepend = listOf("CoreProtect") softDepend = listOf("CoreProtect")
commands { commands {
@ -70,7 +70,7 @@ bukkit {
// Adapted from PlotSquared // Adapted from PlotSquared
val supportedVersions = val supportedVersions =
listOf("1.17.1", "1.18.1", "1.18.2", "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.4") listOf("1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.4", "1.20.6")
tasks { tasks {
supportedVersions.forEach { supportedVersions.forEach {
register<RunServer>("runServer-$it") { register<RunServer>("runServer-$it") {
@ -89,7 +89,7 @@ tasks {
compileJava { compileJava {
options.encoding = Charsets.UTF_8.name() options.encoding = Charsets.UTF_8.name()
options.release.set(17) options.release.set(21)
} }
shadowJar { shadowJar {
@ -98,19 +98,13 @@ tasks {
} }
dependencies { dependencies {
paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT") paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("net.coreprotect:coreprotect:22.2") compileOnly("net.coreprotect:coreprotect:22.4")
implementation("org.bstats:bstats-base:3.0.2") implementation("org.bstats:bstats-base:3.0.2")
implementation("org.bstats:bstats-bukkit:3.0.2") implementation("org.bstats:bstats-bukkit:3.0.2")
implementation(project(path = ":shared", configuration = "shadow")) implementation(project(path = ":shared", configuration = "shadow"))
implementation(project(path = ":v1_20_R4", configuration = "shadow"))
implementation(project(path = ":v1_20_R3", configuration = "shadow")) implementation(project(path = ":v1_20_R3", configuration = "shadow"))
implementation(project(path = ":v1_20_R2", configuration = "shadow")) implementation(project(path = ":v1_20_R2", configuration = "shadow"))
implementation(project(path = ":v1_20_R1", configuration = "shadow"))
implementation(project(path = ":v1_19_R3", configuration = "shadow"))
implementation(project(path = ":v1_19_R2", configuration = "shadow"))
implementation(project(path = ":v1_19_R1", configuration = "shadow"))
implementation(project(path = ":v1_18_R2", configuration = "shadow"))
implementation(project(path = ":v1_18_R1", configuration = "shadow"))
implementation(project(path = ":v1_17_R1", configuration = "shadow"))
} }

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -1,15 +1,9 @@
plugins { plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version ("0.5.0") id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0")
} }
rootProject.name = "ItemizerX" rootProject.name = "ItemizerX"
include("shared") include("shared")
include("v1_20_R4")
include("v1_20_R3") include("v1_20_R3")
include("v1_20_R2") include("v1_20_R2")
include("v1_20_R1")
include("v1_19_R3")
include("v1_19_R2")
include("v1_19_R1")
include("v1_18_R2")
include("v1_18_R1")
include("v1_17_R1")

View File

@ -1,6 +1,7 @@
package dev.plex.itemizerx; package dev.plex.itemizerx;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class ItemizerX extends JavaPlugin public class ItemizerX extends JavaPlugin
@ -23,67 +24,35 @@ public class ItemizerX extends JavaPlugin
new Metrics(this, 19104); new Metrics(this, 19104);
cpb.getCoreProtect(); cpb.getCoreProtect();
getCommand("itemizer").setTabCompleter(new ItemizerXTab()); getCommand("itemizer").setTabCompleter(new ItemizerXTab());
switch (getNMSVersion()) switch (getServerVersion())
{ {
case "v1_20_R3" -> case "1.20.5", "1.20.6" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_20_R4.AttributeManager();
}
case "1.20.4" ->
{ {
getCommand("itemizer").setExecutor(new ItemizerXCommand()); getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_20_R3.AttributeManager(); attr = new dev.plex.itemizerx.v1_20_R3.AttributeManager();
} }
case "v1_20_R2" -> case "1.20.3", "1.20.2" ->
{ {
getCommand("itemizer").setExecutor(new ItemizerXCommand()); getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_20_R2.AttributeManager(); attr = new dev.plex.itemizerx.v1_20_R2.AttributeManager();
} }
case "v1_20_R1" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_20_R1.AttributeManager();
}
case "v1_19_R3" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_19_R3.AttributeManager();
}
case "v1_19_R2" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_19_R2.AttributeManager();
}
case "v1_19_R1" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_19_R1.AttributeManager();
}
case "v1_18_R2" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCommand());
attr = new dev.plex.itemizerx.v1_18_R2.AttributeManager();
}
case "v1_18_R1" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCompatCommand());
attr = new dev.plex.itemizerx.v1_18_R1.AttributeManager();
}
case "v1_17_R1" ->
{
getCommand("itemizer").setExecutor(new ItemizerXCompatCommand());
attr = new dev.plex.itemizerx.v1_17_R1.AttributeManager();
}
default -> default ->
{ {
getLogger().severe("You are trying to run ItemizerX on an incompatible server version."); getLogger().severe("You are trying to run ItemizerX on an incompatible server version.");
getLogger().severe("ItemizerX only supports versions 1.17.1 to 1.20.1, disabling plugin."); getLogger().severe("ItemizerX only supports versions 1.20.2 to 1.20.6, disabling plugin.");
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
} }
} }
} }
public String getNMSVersion() public String getServerVersion()
{ {
String v = getServer().getClass().getPackage().getName(); return Bukkit.getServer().getMinecraftVersion();
return v.substring(v.lastIndexOf('.') + 1);
} }
@Override @Override

42
v1_17_R1/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT")
}

View File

@ -1,164 +0,0 @@
package dev.plex.itemizerx.v1_17_R1;
import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager
{
@Override
public ListTag getAttrList(final ItemStack item)
{
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null)
{
item.getTag().put("AttributeModifiers", new CompoundTag());
}
return item.getTag().getList("AttributeModifiers", 10);
}
@Override
public void addAttr(final Player player, final String[] args)
{
int op;
if (args.length < 4)
{
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
+ "&6Add an attribute"));
return;
}
final Attributes a = Attributes.get(args[2]);
if (a == null)
{
player.sendMessage(colorize("&4\"" + args[2] + "\" is not a valid attribute type."));
return;
}
double amount;
try
{
amount = Double.parseDouble(args[3]);
}
catch (NumberFormatException ex)
{
player.sendMessage(colorize("&4\"" + args[3] + "\" is not a valid number."));
return;
}
if (Double.isNaN(amount))
{
player.sendMessage(colorize("&4Please do not use &f'NaN (Not a Number)'"));
return;
}
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2]))
{
player.sendMessage(colorize("&4An attribute with the name \"&f" + args[2] + "&4\" already exists!"));
return;
}
}
final CompoundTag c = new CompoundTag();
c.putString("Name", args[2]);
c.putString("AttributeName", a.mcName);
c.putDouble("Amount", amount);
op = a.op;
c.putInt("Operation", op);
final Random random = new Random();
c.putIntArray("UUID", new int[]
{
random.nextInt(),
random.nextInt(),
random.nextInt(),
random.nextInt()
});
if (args.length == 5)
{
final List<String> options = new ArrayList<>();
options.add("mainhand");
options.add("offhand");
options.add("head");
options.add("chest");
options.add("legs");
options.add("feet");
if (!options.contains(args[4].toLowerCase()))
{
player.sendMessage(colorize("&2Supported options:\n"
+ "&e" + StringUtils.join(options, ", ")));
return;
}
c.putString("Slot", args[4].toLowerCase());
}
attrmod.add(c);
nms.getTag().put("AttributeModifiers", attrmod);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(colorize("&2Attribute added!"));
}
@Override
public void removeAttr(final Player player, final String string)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
final ListTag newList = new ListTag();
boolean r = false;
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string))
{
newList.add(nbtBase);
}
else
{
r = true;
}
}
if (!r)
{
player.sendMessage(colorize("&4The attribute \"" + string + "\" doesn't exist!"));
return;
}
nms.getTag().put("AttributeModifiers", newList);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(colorize("&2Attribute removed!"));
}
@Override
public void listAttr(final Player player)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
if (attrmod.size() == 0)
{
player.sendMessage(colorize("&eThis item has no attributes."));
return;
}
player.sendMessage(colorize("&2Item attributes: "));
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(colorize("&e" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount")));
}
}
public String colorize(String string)
{
return ChatColor.translateAlternateColorCodes('&', string);
}
}

42
v1_18_R1/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.18.1-R0.1-SNAPSHOT")
}

View File

@ -1,164 +0,0 @@
package dev.plex.itemizerx.v1_18_R1;
import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager
{
@Override
public ListTag getAttrList(final ItemStack item)
{
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null)
{
item.getTag().put("AttributeModifiers", new CompoundTag());
}
return item.getTag().getList("AttributeModifiers", 10);
}
@Override
public void addAttr(final Player player, final String[] args)
{
int op;
if (args.length < 4)
{
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
+ "&6Add an attribute"));
return;
}
final Attributes a = Attributes.get(args[2]);
if (a == null)
{
player.sendMessage(colorize("&4\"" + args[2] + "\" is not a valid attribute type."));
return;
}
double amount;
try
{
amount = Double.parseDouble(args[3]);
}
catch (NumberFormatException ex)
{
player.sendMessage(colorize("&4\"" + args[3] + "\" is not a valid number."));
return;
}
if (Double.isNaN(amount))
{
player.sendMessage(colorize("&4Please do not use &f'NaN (Not a Number)'"));
return;
}
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2]))
{
player.sendMessage(colorize("&4An attribute with the name \"&f" + args[2] + "&4\" already exists!"));
return;
}
}
final CompoundTag c = new CompoundTag();
c.putString("Name", args[2]);
c.putString("AttributeName", a.mcName);
c.putDouble("Amount", amount);
op = a.op;
c.putInt("Operation", op);
final Random random = new Random();
c.putIntArray("UUID", new int[]
{
random.nextInt(),
random.nextInt(),
random.nextInt(),
random.nextInt()
});
if (args.length == 5)
{
final List<String> options = new ArrayList<>();
options.add("mainhand");
options.add("offhand");
options.add("head");
options.add("chest");
options.add("legs");
options.add("feet");
if (!options.contains(args[4].toLowerCase()))
{
player.sendMessage(colorize("&2Supported options:\n"
+ "&e" + StringUtils.join(options, ", ")));
return;
}
c.putString("Slot", args[4].toLowerCase());
}
attrmod.add(c);
nms.getTag().put("AttributeModifiers", attrmod);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(colorize("&2Attribute added!"));
}
@Override
public void removeAttr(final Player player, final String string)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
final ListTag newList = new ListTag();
boolean r = false;
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string))
{
newList.add(nbtBase);
}
else
{
r = true;
}
}
if (!r)
{
player.sendMessage(colorize("&4The attribute \"" + string + "\" doesn't exist!"));
return;
}
nms.getTag().put("AttributeModifiers", newList);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(colorize("&2Attribute removed!"));
}
@Override
public void listAttr(final Player player)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
if (attrmod.size() == 0)
{
player.sendMessage(colorize("&eThis item has no attributes."));
return;
}
player.sendMessage(colorize("&2Item attributes: "));
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(colorize("&e" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount")));
}
}
public String colorize(String string)
{
return ChatColor.translateAlternateColorCodes('&', string);
}
}

42
v1_18_R2/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT")
}

View File

@ -1,161 +0,0 @@
package dev.plex.itemizerx.v1_18_R2;
import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang.StringUtils;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager
{
private final MiniMessage mm = MiniMessage.miniMessage();
@Override
public ListTag getAttrList(final ItemStack item)
{
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null)
{
item.getTag().put("AttributeModifiers", new CompoundTag());
}
return item.getTag().getList("AttributeModifiers", 10);
}
@Override
public void addAttr(final Player player, final String[] args)
{
int op;
if (args.length < 4)
{
player.sendMessage(mm.deserialize("<aqua>/itemizer attr add <<white>name<aqua>> <<white>strength<aqua>>" +
"[<white>slot<aqua>] <red>- <gold>Add an attribute"));
return;
}
final Attributes a = Attributes.get(args[2]);
if (a == null)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[2] + "\" is not a valid attribute type."));
return;
}
double amount;
try
{
amount = Double.parseDouble(args[3]);
}
catch (NumberFormatException ex)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[3] + "\" is not a valid number."));
return;
}
if (Double.isNaN(amount))
{
player.sendMessage(mm.deserialize("<dark_red>Please do not use <white>'NaN (Not a Number)'"));
return;
}
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2]))
{
player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
return;
}
}
final CompoundTag c = new CompoundTag();
c.putString("Name", args[2]);
c.putString("AttributeName", a.mcName);
c.putDouble("Amount", amount);
op = a.op;
c.putInt("Operation", op);
final Random random = new Random();
c.putIntArray("UUID", new int[]
{
random.nextInt(),
random.nextInt(),
random.nextInt(),
random.nextInt()
});
if (args.length == 5)
{
final List<String> options = new ArrayList<>();
options.add("mainhand");
options.add("offhand");
options.add("head");
options.add("chest");
options.add("legs");
options.add("feet");
if (!options.contains(args[4].toLowerCase()))
{
player.sendMessage(mm.deserialize("<dark_green>Supported options:"));
player.sendMessage(mm.deserialize("<yellow>" + StringUtils.join(options, ", ")));
return;
}
c.putString("Slot", args[4].toLowerCase());
}
attrmod.add(c);
nms.getTag().put("AttributeModifiers", attrmod);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_aqua>Attribute added!"));
}
@Override
public void removeAttr(final Player player, final String string)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
final ListTag newList = new ListTag();
boolean r = false;
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string))
{
newList.add(nbtBase);
}
else
{
r = true;
}
}
if (!r)
{
player.sendMessage(mm.deserialize("<dark_red>The attribute \"" + string + "\" doesn't exist!"));
return;
}
nms.getTag().put("AttributeModifiers", newList);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_green>Attribute removed!"));
}
@Override
public void listAttr(final Player player)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
if (attrmod.size() == 0)
{
player.sendMessage(mm.deserialize("<yellow>This item has no attributes."));
return;
}
player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount")));
}
}
}

42
v1_19_R1/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT")
}

View File

@ -1,161 +0,0 @@
package dev.plex.itemizerx.v1_19_R1;
import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager
{
private final MiniMessage mm = MiniMessage.miniMessage();
@Override
public ListTag getAttrList(final ItemStack item)
{
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null)
{
item.getTag().put("AttributeModifiers", new CompoundTag());
}
return item.getTag().getList("AttributeModifiers", 10);
}
@Override
public void addAttr(final Player player, final String[] args)
{
int op;
if (args.length < 4)
{
player.sendMessage(mm.deserialize("<aqua>/itemizer attr add <<white>name<aqua>> <<white>strength<aqua>>" +
"[<white>slot<aqua>] <red>- <gold>Add an attribute"));
return;
}
final Attributes a = Attributes.get(args[2]);
if (a == null)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[2] + "\" is not a valid attribute type."));
return;
}
double amount;
try
{
amount = Double.parseDouble(args[3]);
}
catch (NumberFormatException ex)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[3] + "\" is not a valid number."));
return;
}
if (Double.isNaN(amount))
{
player.sendMessage(mm.deserialize("<dark_red>Please do not use <white>'NaN (Not a Number)'"));
return;
}
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2]))
{
player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
return;
}
}
final CompoundTag c = new CompoundTag();
c.putString("Name", args[2]);
c.putString("AttributeName", a.mcName);
c.putDouble("Amount", amount);
op = a.op;
c.putInt("Operation", op);
final Random random = new Random();
c.putIntArray("UUID", new int[]
{
random.nextInt(),
random.nextInt(),
random.nextInt(),
random.nextInt()
});
if (args.length == 5)
{
final List<String> options = new ArrayList<>();
options.add("mainhand");
options.add("offhand");
options.add("head");
options.add("chest");
options.add("legs");
options.add("feet");
if (!options.contains(args[4].toLowerCase()))
{
player.sendMessage(mm.deserialize("<dark_green>Supported options:"));
player.sendMessage(mm.deserialize("<yellow>" + StringUtils.join(options, ", ")));
return;
}
c.putString("Slot", args[4].toLowerCase());
}
attrmod.add(c);
nms.getTag().put("AttributeModifiers", attrmod);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_aqua>Attribute added!"));
}
@Override
public void removeAttr(final Player player, final String string)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
final ListTag newList = new ListTag();
boolean r = false;
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string))
{
newList.add(nbtBase);
}
else
{
r = true;
}
}
if (!r)
{
player.sendMessage(mm.deserialize("<dark_red>The attribute \"" + string + "\" doesn't exist!"));
return;
}
nms.getTag().put("AttributeModifiers", newList);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_green>Attribute removed!"));
}
@Override
public void listAttr(final Player player)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
if (attrmod.size() == 0)
{
player.sendMessage(mm.deserialize("<yellow>This item has no attributes."));
return;
}
player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount")));
}
}
}

42
v1_19_R2/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.19.3-R0.1-SNAPSHOT")
}

42
v1_19_R3/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT")
}

View File

@ -1,161 +0,0 @@
package dev.plex.itemizerx.v1_19_R3;
import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager
{
private final MiniMessage mm = MiniMessage.miniMessage();
@Override
public ListTag getAttrList(final ItemStack item)
{
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null)
{
item.getTag().put("AttributeModifiers", new CompoundTag());
}
return item.getTag().getList("AttributeModifiers", 10);
}
@Override
public void addAttr(final Player player, final String[] args)
{
int op;
if (args.length < 4)
{
player.sendMessage(mm.deserialize("<aqua>/itemizer attr add <<white>name<aqua>> <<white>strength<aqua>>" +
"[<white>slot<aqua>] <red>- <gold>Add an attribute"));
return;
}
final Attributes a = Attributes.get(args[2]);
if (a == null)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[2] + "\" is not a valid attribute type."));
return;
}
double amount;
try
{
amount = Double.parseDouble(args[3]);
}
catch (NumberFormatException ex)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[3] + "\" is not a valid number."));
return;
}
if (Double.isNaN(amount))
{
player.sendMessage(mm.deserialize("<dark_red>Please do not use <white>'NaN (Not a Number)'"));
return;
}
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2]))
{
player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
return;
}
}
final CompoundTag c = new CompoundTag();
c.putString("Name", args[2]);
c.putString("AttributeName", a.mcName);
c.putDouble("Amount", amount);
op = a.op;
c.putInt("Operation", op);
final Random random = new Random();
c.putIntArray("UUID", new int[]
{
random.nextInt(),
random.nextInt(),
random.nextInt(),
random.nextInt()
});
if (args.length == 5)
{
final List<String> options = new ArrayList<>();
options.add("mainhand");
options.add("offhand");
options.add("head");
options.add("chest");
options.add("legs");
options.add("feet");
if (!options.contains(args[4].toLowerCase()))
{
player.sendMessage(mm.deserialize("<dark_green>Supported options:"));
player.sendMessage(mm.deserialize("<yellow>" + StringUtils.join(options, ", ")));
return;
}
c.putString("Slot", args[4].toLowerCase());
}
attrmod.add(c);
nms.getTag().put("AttributeModifiers", attrmod);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_aqua>Attribute added!"));
}
@Override
public void removeAttr(final Player player, final String string)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
final ListTag newList = new ListTag();
boolean r = false;
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string))
{
newList.add(nbtBase);
}
else
{
r = true;
}
}
if (!r)
{
player.sendMessage(mm.deserialize("<dark_red>The attribute \"" + string + "\" doesn't exist!"));
return;
}
nms.getTag().put("AttributeModifiers", newList);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_green>Attribute removed!"));
}
@Override
public void listAttr(final Player player)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
if (attrmod.size() == 0)
{
player.sendMessage(mm.deserialize("<yellow>This item has no attributes."));
return;
}
player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount")));
}
}
}

42
v1_20_R1/.gitignore vendored
View File

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,3 +0,0 @@
dependencies {
paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT")
}

View File

@ -1,161 +0,0 @@
package dev.plex.itemizerx.v1_20_R1;
import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager
{
private final MiniMessage mm = MiniMessage.miniMessage();
@Override
public ListTag getAttrList(final ItemStack item)
{
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null)
{
item.getTag().put("AttributeModifiers", new CompoundTag());
}
return item.getTag().getList("AttributeModifiers", 10);
}
@Override
public void addAttr(final Player player, final String[] args)
{
int op;
if (args.length < 4)
{
player.sendMessage(mm.deserialize("<aqua>/itemizer attr add <<white>name<aqua>> <<white>strength<aqua>>" +
"[<white>slot<aqua>] <red>- <gold>Add an attribute"));
return;
}
final Attributes a = Attributes.get(args[2]);
if (a == null)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[2] + "\" is not a valid attribute type."));
return;
}
double amount;
try
{
amount = Double.parseDouble(args[3]);
}
catch (NumberFormatException ex)
{
player.sendMessage(mm.deserialize("<dark_red>\"" + args[3] + "\" is not a valid number."));
return;
}
if (Double.isNaN(amount))
{
player.sendMessage(mm.deserialize("<dark_red>Please do not use <white>'NaN (Not a Number)'"));
return;
}
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2]))
{
player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
return;
}
}
final CompoundTag c = new CompoundTag();
c.putString("Name", args[2]);
c.putString("AttributeName", a.mcName);
c.putDouble("Amount", amount);
op = a.op;
c.putInt("Operation", op);
final Random random = new Random();
c.putIntArray("UUID", new int[]
{
random.nextInt(),
random.nextInt(),
random.nextInt(),
random.nextInt()
});
if (args.length == 5)
{
final List<String> options = new ArrayList<>();
options.add("mainhand");
options.add("offhand");
options.add("head");
options.add("chest");
options.add("legs");
options.add("feet");
if (!options.contains(args[4].toLowerCase()))
{
player.sendMessage(mm.deserialize("<dark_green>Supported options:"));
player.sendMessage(mm.deserialize("<yellow>" + StringUtils.join(options, ", ")));
return;
}
c.putString("Slot", args[4].toLowerCase());
}
attrmod.add(c);
nms.getTag().put("AttributeModifiers", attrmod);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_aqua>Attribute added!"));
}
@Override
public void removeAttr(final Player player, final String string)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
final ListTag newList = new ListTag();
boolean r = false;
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string))
{
newList.add(nbtBase);
}
else
{
r = true;
}
}
if (!r)
{
player.sendMessage(mm.deserialize("<dark_red>The attribute \"" + string + "\" doesn't exist!"));
return;
}
nms.getTag().put("AttributeModifiers", newList);
final org.bukkit.inventory.ItemStack is = CraftItemStack.asCraftMirror(nms);
player.getInventory().setItemInMainHand(is);
player.sendMessage(mm.deserialize("<dark_green>Attribute removed!"));
}
@Override
public void listAttr(final Player player)
{
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
final ListTag attrmod = getAttrList(nms);
if (attrmod.size() == 0)
{
player.sendMessage(mm.deserialize("<yellow>This item has no attributes."));
return;
}
player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod)
{
final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount")));
}
}
}

View File

@ -0,0 +1,3 @@
dependencies {
paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
}

View File

@ -1,4 +1,4 @@
package dev.plex.itemizerx.v1_19_R2; /*package dev.plex.itemizerx.v1_20_R4;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
@ -8,7 +8,7 @@ import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,7 +25,7 @@ public class AttributeManager implements IAttributeManager
ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10); ListTag attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
if (attrmod == null) if (attrmod == null)
{ {
item.getTag().put("AttributeModifiers", new CompoundTag()); item.put("AttributeModifiers", new CompoundTag());
} }
return item.getTag().getList("AttributeModifiers", 10); return item.getTag().getList("AttributeModifiers", 10);
} }
@ -159,3 +159,4 @@ public class AttributeManager implements IAttributeManager
} }
} }
} }
*/