From ae57573eeb218ab97d88d057c564e5672e109d2e Mon Sep 17 00:00:00 2001 From: Nathan Curran <30569566+Focusvity@users.noreply.github.com> Date: Tue, 4 Aug 2020 11:39:59 +1000 Subject: [PATCH 1/2] Fixed modifyitem command --- .../command/Command_modifyitem.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java index 9002dccd..2e094a38 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import java.util.ArrayList; import java.util.List; +import java.util.Random; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import net.minecraft.server.v1_16_R1.NBTTagCompound; @@ -160,23 +161,34 @@ public class Command_modifyitem extends FreedomCommand msg("Invalid attribute. Please run /attributelist for a list of valid attributes."); return true; } - cmpnd.set("AttributeName", NBTTagString.a(attribute.getAttribute())); - cmpnd.set("Name", NBTTagString.a(attribute.getAttribute())); - int amount; + cmpnd.setString("AttributeName", attribute.getAttribute()); + cmpnd.setString("Name", attribute.getAttribute()); + double amount; try { - amount = Integer.parseInt(args[2]); + amount = Double.parseDouble(args[2]); } catch (NumberFormatException ex) { msg("The amount specified is not a valid integer."); return true; } - cmpnd.set("Amount", NBTTagInt.a(amount)); - cmpnd.set("Operation", NBTTagInt.a(0)); - cmpnd.set("UUIDLeast", NBTTagInt.a(894654)); - cmpnd.set("UUIDMost", NBTTagInt.a(2872)); - cmpnd.set("Slot", NBTTagString.a("mainhand")); + if (Double.isNaN(amount)) + { + msg("The amount specified is illegal."); + return true; + } + cmpnd.setDouble("Amount", amount); + cmpnd.setInt("Operation", 0); + Random random = new Random(); + cmpnd.setIntArray("UUID", new int[] + { + random.nextInt(), + random.nextInt(), + random.nextInt(), + random.nextInt() + }); + cmpnd.setString("Slot", "mainhand"); modifiers.add(cmpnd); compound.set("AttributeModifiers", modifiers); nmsStack.setTag(compound); From c826afe399f75b690e8d029cc993817f2fbcada0 Mon Sep 17 00:00:00 2001 From: Nathan Curran <30569566+Focusvity@users.noreply.github.com> Date: Tue, 4 Aug 2020 11:44:01 +1000 Subject: [PATCH 2/2] Removed some imports --- .../totalfreedommod/command/Command_modifyitem.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java index 2e094a38..96b9ebc6 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java @@ -6,9 +6,7 @@ import java.util.Random; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import net.minecraft.server.v1_16_R1.NBTTagCompound; -import net.minecraft.server.v1_16_R1.NBTTagInt; import net.minecraft.server.v1_16_R1.NBTTagList; -import net.minecraft.server.v1_16_R1.NBTTagString; import org.apache.commons.lang.StringUtils; import org.bukkit.Material; import org.bukkit.command.Command;