mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-30 13:27:37 +00:00
fixed
offline player lookup should work now, but i still need to allow for nbt data lookup as well.
This commit is contained in:
parent
135d1af27d
commit
c096c4a781
@ -10,8 +10,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "View player inventory information of players.", usage = "/<command> <player> <slot>", aliases = "inv")
|
||||
public class Command_inventory extends FreedomCommand
|
||||
@CommandParameters(description = "View inventory information of players.", usage = "/<command> <player> <slot>", aliases = "il,invlookup")
|
||||
public class Command_inventorylookup extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
@ -48,7 +48,7 @@ public class Command_inventory extends FreedomCommand
|
||||
msg(" - Amount: " + stack.getAmount());
|
||||
if (inv.hasNBT(slot))
|
||||
{
|
||||
msg(" - NBT Data: " + inv.getNBT(slot));
|
||||
msg(" - NBT Data: " + inv.getNBT(slot).toString());
|
||||
}
|
||||
return true;
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||
@ -21,6 +22,17 @@ public class ConfigInventory
|
||||
updateInventory(inv);
|
||||
}
|
||||
|
||||
public void set(int location, Material material, int amount, NBTTagCompound nbt)
|
||||
{
|
||||
ItemStack stack = new ItemStack(material, amount);
|
||||
/*
|
||||
net.minecraft.server.v1_14_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack);
|
||||
nmsStack.setTag(nbt);
|
||||
stack = CraftItemStack.asBukkitCopy(nmsStack);
|
||||
*/
|
||||
inventoryItems.put(location, stack);
|
||||
}
|
||||
|
||||
public void set(int location, ItemStack stack)
|
||||
{
|
||||
inventoryItems.put(location, stack);
|
||||
@ -36,14 +48,18 @@ public class ConfigInventory
|
||||
return CraftItemStack.asNMSCopy(inventoryItems.get(location)).hasTag();
|
||||
}
|
||||
|
||||
public String getNBT(int location)
|
||||
public NBTTagCompound getNBT(int location)
|
||||
{
|
||||
return CraftItemStack.asNMSCopy(inventoryItems.get(location)).getTag().toString();
|
||||
return CraftItemStack.asNMSCopy(inventoryItems.get(location)).getTag();
|
||||
}
|
||||
|
||||
public void updateInventory(Inventory inv)
|
||||
{
|
||||
inventoryItems = new HashMap<>();
|
||||
if (inv == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < inv.getSize(); i++)
|
||||
{
|
||||
inventoryItems.put(i, inv.getItem(i));
|
||||
@ -70,4 +86,16 @@ public class ConfigInventory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigInventory createInventoryFromConfig(ConfigurationSection cs)
|
||||
{
|
||||
ConfigInventory configInventory = new ConfigInventory(null);
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
configInventory.set(i, Material.valueOf(cs.getString("inventory." + i + ".type")),
|
||||
cs.getInt("inventory." + i + ".amount"), null);//,
|
||||
//(NBTTagCompound) cs.get("inventory." + i + ".nbt"));
|
||||
}
|
||||
return configInventory;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,14 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
|
||||
tag = cs.getString("tag", null);
|
||||
clearChatOptOut = cs.getBoolean("clearChatOptOut", false);
|
||||
rideToggle = cs.getBoolean("rideToggle", true);
|
||||
inventory = new ConfigInventory(Bukkit.getPlayer(name).getInventory());
|
||||
if (!cs.contains("inventory") || Bukkit.getPlayer(name) != null)
|
||||
{
|
||||
inventory = new ConfigInventory(Bukkit.getPlayer(name).getInventory());
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory = ConfigInventory.createInventoryFromConfig(cs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user