Reformat and add missing attribute

This commit is contained in:
Telesphoreo 2023-07-24 12:27:29 -05:00
parent a07c68e4b3
commit 57be14698f
No known key found for this signature in database
GPG Key ID: 68B745F7F8C2FADA
14 changed files with 128 additions and 95 deletions

View File

@ -1,5 +1,5 @@
plugins { plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.5.0") id("org.gradle.toolchains.foojay-resolver-convention") version ("0.5.0")
} }
rootProject.name = "ItemizerX" rootProject.name = "ItemizerX"

View File

@ -5,17 +5,18 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public enum Attributes { public enum Attributes
{
MAX_HEALTH("generic.max_health", 0), MAX_HEALTH("generic.max_health", 0),
FOLLOW_RANGE("generic.follow_range", 1), FOLLOW_RANGE("generic.follow_range", 1),
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1), KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
MOVEMENT_SPEED("generic.movement_speed", 1), MOVEMENT_SPEED("generic.movement_speed", 1),
FLYING_SPEED("generic.flying_speed", 1),
DAMAGE("generic.attack_damage", 0), DAMAGE("generic.attack_damage", 0),
ATTACK_KNOCKBACK("generic.attack_knockback", 0),
ATTACK_SPEED("generic.attack_speed", 1),
ARMOR("generic.armor", 0), ARMOR("generic.armor", 0),
ARMOR_TOUGHNESS("generic.armor_toughness", 0), ARMOR_TOUGHNESS("generic.armor_toughness", 0),
FLYING_SPEED("generic.flying_speed", 1),
ATTACK_SPEED("generic.attack_speed", 1),
LUCK("generic.luck", 0), LUCK("generic.luck", 0),
HORSE_JUMP("horse.jump_strength", 1), HORSE_JUMP("horse.jump_strength", 1),
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1); ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
@ -23,27 +24,34 @@ public enum Attributes {
public final String mcName; public final String mcName;
public final int op; public final int op;
Attributes(String mcName, int op) { Attributes(String mcName, int op)
{
this.mcName = mcName; this.mcName = mcName;
this.op = op; this.op = op;
} }
public static Attributes get(String name) { public static Attributes get(String name)
for (Attributes attr : values()) { {
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) { for (Attributes attr : values())
{
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name))
{
return attr; return attr;
} }
} }
return null; return null;
} }
public static String getAttributes() { public static String getAttributes()
{
return StringUtils.join(values(), ", "); return StringUtils.join(values(), ", ");
} }
public static List<String> getAttributeList() { public static List<String> getAttributeList()
{
List<String> attributes = new ArrayList<>(); List<String> attributes = new ArrayList<>();
for (Attributes attr : values()) { for (Attributes attr : values())
{
attributes.add(attr.name()); attributes.add(attr.name());
} }
return attributes; return attributes;

View File

@ -5,40 +5,55 @@ import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class CoreProtectBridge { public class CoreProtectBridge
{
public static CoreProtect cp = null; public static CoreProtect cp = null;
public static CoreProtectAPI api = null; public static CoreProtectAPI api = null;
public static boolean logged = false; public static boolean logged = false;
public CoreProtect getCoreProtect() { public CoreProtect getCoreProtect()
try { {
try
{
final Plugin pl = Bukkit.getPluginManager().getPlugin("CoreProtect"); final Plugin pl = Bukkit.getPluginManager().getPlugin("CoreProtect");
if (pl instanceof CoreProtect) { if (pl instanceof CoreProtect)
{
cp = (CoreProtect) pl; cp = (CoreProtect) pl;
} else { }
if (!logged) { // To stop the console log spam - not persistent on server restarts else
{
if (!logged)
{ // To stop the console log spam - not persistent on server restarts
Bukkit.getLogger().info("CoreProtect not detected, some features will not be logged!"); Bukkit.getLogger().info("CoreProtect not detected, some features will not be logged!");
logged = true; logged = true;
} }
} }
} catch (Exception ex) { }
catch (Exception ex)
{
ex.printStackTrace(); ex.printStackTrace();
} }
return cp; return cp;
} }
public CoreProtectAPI getAPI() { public CoreProtectAPI getAPI()
{
final CoreProtect cp = getCoreProtect(); final CoreProtect cp = getCoreProtect();
if (cp != null && api == null) { if (cp != null && api == null)
try { {
try
{
api = cp.getAPI(); api = cp.getAPI();
if (!cp.isEnabled() || !api.isEnabled()) { if (!cp.isEnabled() || !api.isEnabled())
{
Bukkit.getLogger().info("CoreProtect is disabled, some features will not be logged!"); Bukkit.getLogger().info("CoreProtect is disabled, some features will not be logged!");
return null; return null;
} }
} catch (Exception ex) { }
catch (Exception ex)
{
ex.printStackTrace(); ex.printStackTrace();
} }
} }

View File

@ -1,9 +1,5 @@
package dev.plex.itemizerx; package dev.plex.itemizerx;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -27,6 +23,11 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class ItemizerXCommand implements CommandExecutor, ItemizerXBase public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
{ {
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION); final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
@ -348,7 +349,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
return true; return true;
} }
final PotionEffect pot = new PotionEffect(potType, tick, level); final PotionEffect pot = new PotionEffect(potType, tick, level);
final PotionMeta potionMeta = (PotionMeta)meta; final PotionMeta potionMeta = (PotionMeta) meta;
assert potionMeta != null; assert potionMeta != null;
if (potionMeta.hasCustomEffect(pot.getType())) if (potionMeta.hasCustomEffect(pot.getType()))
{ {
@ -379,7 +380,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
sender.sendMessage(mm.deserialize("<dark_red>The potion effect <white>\"" + args[2] + "<white>\" <dark_red>does not exist!")); sender.sendMessage(mm.deserialize("<dark_red>The potion effect <white>\"" + args[2] + "<white>\" <dark_red>does not exist!"));
return true; return true;
} }
final PotionMeta potionMeta = (PotionMeta)meta; final PotionMeta potionMeta = (PotionMeta) meta;
assert potionMeta != null; assert potionMeta != null;
if (!potionMeta.hasCustomEffect(potType)) if (!potionMeta.hasCustomEffect(potType))
{ {
@ -427,7 +428,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
sender.sendMessage(mm.deserialize("<aqua>/itemizer potion color <<white>hexcolor<aqua>> <red>- <gold>Set the potion color")); sender.sendMessage(mm.deserialize("<aqua>/itemizer potion color <<white>hexcolor<aqua>> <red>- <gold>Set the potion color"));
return true; return true;
} }
final PotionMeta potionMeta = (PotionMeta)meta; final PotionMeta potionMeta = (PotionMeta) meta;
assert potionMeta != null; assert potionMeta != null;
try try
{ {
@ -818,7 +819,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
return true; return true;
} }
Component name = mm.deserialize(StringUtils.join(args, " ", 1, args.length)); Component name = mm.deserialize(StringUtils.join(args, " ", 1, args.length));
final BookMeta bookMeta = (BookMeta)meta; final BookMeta bookMeta = (BookMeta) meta;
assert bookMeta != null; assert bookMeta != null;
bookMeta.title(name); bookMeta.title(name);
item.setItemMeta(bookMeta); item.setItemMeta(bookMeta);
@ -844,7 +845,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
return true; return true;
} }
Component name = mm.deserialize(args[1]); Component name = mm.deserialize(args[1]);
final BookMeta bookMeta = (BookMeta)meta; final BookMeta bookMeta = (BookMeta) meta;
assert bookMeta != null; assert bookMeta != null;
bookMeta.author(name); bookMeta.author(name);
item.setItemMeta(bookMeta); item.setItemMeta(bookMeta);
@ -874,7 +875,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
{ {
name = name.substring(0, 16); name = name.substring(0, 16);
} }
final SkullMeta skullMeta = (SkullMeta)meta; final SkullMeta skullMeta = (SkullMeta) meta;
assert skullMeta != null; assert skullMeta != null;
skullMeta.setOwner(name); skullMeta.setOwner(name);
item.setItemMeta(skullMeta); item.setItemMeta(skullMeta);
@ -915,7 +916,7 @@ public class ItemizerXCommand implements CommandExecutor, ItemizerXBase
{ {
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData()); cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
} }
Sign sign = (Sign)block.getState(); Sign sign = (Sign) block.getState();
sign.line(line - 1, text); sign.line(line - 1, text);
sign.update(); sign.update();
if (cpb.getAPI() != null) if (cpb.getAPI() != null)

View File

@ -1,11 +1,5 @@
package dev.plex.itemizerx; package dev.plex.itemizerx;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
@ -28,6 +22,13 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
{ {
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION); final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
@ -352,7 +353,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
return true; return true;
} }
final PotionEffect pot = new PotionEffect(potType, tick, level); final PotionEffect pot = new PotionEffect(potType, tick, level);
final PotionMeta potionMeta = (PotionMeta)meta; final PotionMeta potionMeta = (PotionMeta) meta;
assert potionMeta != null; assert potionMeta != null;
if (potionMeta.hasCustomEffect(pot.getType())) if (potionMeta.hasCustomEffect(pot.getType()))
{ {
@ -383,7 +384,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
sender.sendMessage(colorize("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!")); sender.sendMessage(colorize("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!"));
return true; return true;
} }
final PotionMeta potionMeta = (PotionMeta)meta; final PotionMeta potionMeta = (PotionMeta) meta;
assert potionMeta != null; assert potionMeta != null;
if (!potionMeta.hasCustomEffect(potType)) if (!potionMeta.hasCustomEffect(potType))
{ {
@ -434,7 +435,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color")); + "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
return true; return true;
} }
final PotionMeta potionMeta = (PotionMeta)meta; final PotionMeta potionMeta = (PotionMeta) meta;
assert potionMeta != null; assert potionMeta != null;
try try
{ {
@ -830,7 +831,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
return true; return true;
} }
String name = colorize(StringUtils.join(args, " ", 1, args.length)); String name = colorize(StringUtils.join(args, " ", 1, args.length));
final BookMeta bookMeta = (BookMeta)meta; final BookMeta bookMeta = (BookMeta) meta;
assert bookMeta != null; assert bookMeta != null;
bookMeta.setTitle(name); bookMeta.setTitle(name);
item.setItemMeta(bookMeta); item.setItemMeta(bookMeta);
@ -856,7 +857,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
return true; return true;
} }
String name = colorize(args[1]); String name = colorize(args[1]);
final BookMeta bookMeta = (BookMeta)meta; final BookMeta bookMeta = (BookMeta) meta;
assert bookMeta != null; assert bookMeta != null;
bookMeta.setAuthor(name); bookMeta.setAuthor(name);
item.setItemMeta(bookMeta); item.setItemMeta(bookMeta);
@ -886,7 +887,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
{ {
name = name.substring(0, 16); name = name.substring(0, 16);
} }
final SkullMeta skullMeta = (SkullMeta)meta; final SkullMeta skullMeta = (SkullMeta) meta;
assert skullMeta != null; assert skullMeta != null;
skullMeta.setOwner(name); skullMeta.setOwner(name);
item.setItemMeta(skullMeta); item.setItemMeta(skullMeta);
@ -928,7 +929,7 @@ public class ItemizerXCompatCommand implements CommandExecutor, ItemizerXBase
{ {
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData()); cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
} }
Sign sign = (Sign)block.getState(); Sign sign = (Sign) block.getState();
sign.setLine(line - 1, text); sign.setLine(line - 1, text);
sign.update(); sign.update();
if (cpb.getAPI() != null) if (cpb.getAPI() != null)

View File

@ -1,9 +1,5 @@
package dev.plex.itemizerx; package dev.plex.itemizerx;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -12,6 +8,11 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class ItemizerXTab implements TabCompleter public class ItemizerXTab implements TabCompleter
{ {
@Override @Override

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_17_R1;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@ -14,6 +11,10 @@ import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
@Override @Override
@ -62,7 +63,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) if (c.getString("Name").equals(args[2]))
{ {
player.sendMessage(colorize("&4An attribute with the name \"&f" + args[2] + "&4\" already exists!")); player.sendMessage(colorize("&4An attribute with the name \"&f" + args[2] + "&4\" already exists!"));
@ -116,7 +117,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -150,7 +151,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(colorize("&2Item attributes: ")); player.sendMessage(colorize("&2Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(colorize("&e" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(colorize("&e" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_18_R1;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@ -14,6 +11,10 @@ import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
@Override @Override
@ -62,7 +63,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) if (c.getString("Name").equals(args[2]))
{ {
player.sendMessage(colorize("&4An attribute with the name \"&f" + args[2] + "&4\" already exists!")); player.sendMessage(colorize("&4An attribute with the name \"&f" + args[2] + "&4\" already exists!"));
@ -116,7 +117,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -150,7 +151,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(colorize("&2Item attributes: ")); player.sendMessage(colorize("&2Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(colorize("&e" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(colorize("&e" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_18_R2;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
@ -14,6 +11,10 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
private final MiniMessage mm = MiniMessage.miniMessage(); private final MiniMessage mm = MiniMessage.miniMessage();
@ -64,7 +65,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) 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!")); player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
@ -118,7 +119,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -152,7 +153,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(mm.deserialize("<dark_green>Item attributes: ")); player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_19_R1;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
@ -14,6 +11,10 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
private final MiniMessage mm = MiniMessage.miniMessage(); private final MiniMessage mm = MiniMessage.miniMessage();
@ -64,7 +65,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) 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!")); player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
@ -118,7 +119,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -152,7 +153,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(mm.deserialize("<dark_green>Item attributes: ")); player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_19_R2;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
@ -14,6 +11,10 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
private final MiniMessage mm = MiniMessage.miniMessage(); private final MiniMessage mm = MiniMessage.miniMessage();
@ -64,7 +65,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) 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!")); player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
@ -118,7 +119,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -152,7 +153,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(mm.deserialize("<dark_green>Item attributes: ")); player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_19_R3;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
@ -14,6 +11,10 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
private final MiniMessage mm = MiniMessage.miniMessage(); private final MiniMessage mm = MiniMessage.miniMessage();
@ -64,7 +65,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) 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!")); player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
@ -118,7 +119,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -152,7 +153,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(mm.deserialize("<dark_green>Item attributes: ")); player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }

View File

@ -2,9 +2,6 @@ package dev.plex.itemizerx.v1_20_R1;
import dev.plex.itemizerx.Attributes; import dev.plex.itemizerx.Attributes;
import dev.plex.itemizerx.IAttributeManager; import dev.plex.itemizerx.IAttributeManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
@ -14,6 +11,10 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class AttributeManager implements IAttributeManager public class AttributeManager implements IAttributeManager
{ {
private final MiniMessage mm = MiniMessage.miniMessage(); private final MiniMessage mm = MiniMessage.miniMessage();
@ -64,7 +65,7 @@ public class AttributeManager implements IAttributeManager
final ListTag attrmod = getAttrList(nms); final ListTag attrmod = getAttrList(nms);
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (c.getString("Name").equals(args[2])) 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!")); player.sendMessage(mm.deserialize("<dark_red>An attribute with the name \"<white>" + args[2] + "<dark_red>\" already exists!"));
@ -118,7 +119,7 @@ public class AttributeManager implements IAttributeManager
boolean r = false; boolean r = false;
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
if (!c.getString("Name").equals(string)) if (!c.getString("Name").equals(string))
{ {
newList.add(nbtBase); newList.add(nbtBase);
@ -152,7 +153,7 @@ public class AttributeManager implements IAttributeManager
player.sendMessage(mm.deserialize("<dark_green>Item attributes: ")); player.sendMessage(mm.deserialize("<dark_green>Item attributes: "));
for (Tag nbtBase : attrmod) for (Tag nbtBase : attrmod)
{ {
final CompoundTag c = (CompoundTag)nbtBase; final CompoundTag c = (CompoundTag) nbtBase;
player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName player.sendMessage(mm.deserialize("<yellow>" + Attributes.get(c.getString("AttributeName")).mcName
+ ", " + c.getDouble("Amount"))); + ", " + c.getDouble("Amount")));
} }