0.5.3
bug fixes
This commit is contained in:
parent
cace53df3d
commit
1717733fab
14 changed files with 348 additions and 27 deletions
|
@ -80,7 +80,7 @@ dependencies {
|
|||
}
|
||||
|
||||
group = 'gq.unurled'
|
||||
version = '0.5.2'
|
||||
version = '0.5.3'
|
||||
description = 'Raxen'
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static gq.unurled.raxen.utils.Utils.colorComp;
|
|||
public final class Raxen extends JavaPlugin {
|
||||
|
||||
private static final String prefix = "<aqua>Rx</aqua><light_purple>></light_purple> ";
|
||||
@Getter private static String version = "0.5.2";
|
||||
@Getter private static String version = "0.5.3";
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
private static Raxen plugin;
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package gq.unurled.raxen.commands.player;
|
||||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.gui.MainGui;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.errorConsoleSender;
|
||||
import static gq.unurled.raxen.utils.Utils.noPerms;
|
||||
|
||||
public class MainGuiCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
public MainGuiCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (!(p.hasPermission("raxen.maingui.cmd"))) {
|
||||
sender.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
Inventory inv = MainGui.build(p);
|
||||
p.openInventory(inv);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
|
@ -57,7 +58,7 @@ public class RaxenPlayer {
|
|||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
String store = data.get(namespacedKey.storage, PersistentDataType.STRING);
|
||||
org.bukkit.inventory.Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
ec = setItemsToInventory(Items.listItemStackDeserialize(store), ec);
|
||||
ec = setItemsToInventory(Items.mapItemStackDeserialize(store), ec);
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
return storage;
|
||||
|
@ -67,7 +68,8 @@ public class RaxenPlayer {
|
|||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
String inv = data.get(namespacedKey.inventory, PersistentDataType.STRING);
|
||||
org.bukkit.inventory.Inventory invv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||
invv = setItemsToInventory(Items.listItemStackDeserialize(inv), invv);
|
||||
PlayerInventory invvvvv = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER);
|
||||
invv = setItemsToInventory(Items.listItemStackDeserialize(inv), invvvvv);
|
||||
Inventory invvv = new Inventory(invv);
|
||||
Inventories invvvv = new Inventories(invvv);
|
||||
return invvvv;
|
||||
|
|
71
src/main/java/gq/unurled/raxen/components/gui/MainGui.java
Normal file
71
src/main/java/gq/unurled/raxen/components/gui/MainGui.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
package gq.unurled.raxen.components.gui;
|
||||
|
||||
import gq.unurled.raxen.utils.Items;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.colorComp;
|
||||
import static gq.unurled.raxen.utils.Utils.fillGreyPane;
|
||||
|
||||
public class MainGui {
|
||||
|
||||
public static Inventory build(Player p) {
|
||||
Inventory inv = Bukkit.createInventory(null, 54, colorComp("<dark_grey>Raxen</dark_grey>"));
|
||||
String gui = "0,7,0,0,0,8,9,0,10," +
|
||||
"0,0,0,0,0,0,0,0,0," +
|
||||
"0,0,0,0,0,0,0,0,0," +
|
||||
"0,2,3,0,0,0,0,4,0," +
|
||||
"0,0,0,0,1,0,0,0,0," +
|
||||
"0,0,0,0,0,0,0,0,0";
|
||||
// 1 player Head
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta headm = (SkullMeta) head.getItemMeta();
|
||||
headm.setOwningPlayer(p.getPlayer());
|
||||
headm.displayName(colorComp("<green></green>"));
|
||||
// 2 bank
|
||||
ItemStack bank = new ItemStack(Material.GOLD_INGOT);
|
||||
// 3 ah
|
||||
ItemStack ah = new ItemStack(Material.GOLD_INGOT);
|
||||
// 4 skill tree
|
||||
ItemStack sk_tree = new ItemStack(Material.OAK_SAPLING);
|
||||
// 7 teleport
|
||||
ItemStack tp = new ItemStack(Material.ENDER_PEARL);
|
||||
// 8 select character
|
||||
ItemStack sel_char = new ItemStack(Material.SNOWBALL);
|
||||
// 9 Settings
|
||||
ItemStack sett = new ItemStack(Material.MAGMA_CREAM);
|
||||
// 10 barrier block close
|
||||
|
||||
HashMap<String, ItemStack> list = new HashMap<>();
|
||||
list.put("1", head);
|
||||
list.put("2", bank);
|
||||
list.put("3",ah);
|
||||
list.put("4", sk_tree);
|
||||
list.put("7", tp);
|
||||
list.put("8", sel_char);
|
||||
list.put("9", sett);
|
||||
list.put("10", Items.closeItem());
|
||||
Inventory inventory = stringToGui(inv, gui,list);
|
||||
inventory = fillGreyPane(inventory);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public static Inventory stringToGui(Inventory inv, String stt, HashMap<String, ItemStack> it) {
|
||||
String[] s = stt.split(",");
|
||||
if (s.length != inv.getContents().length) {
|
||||
return inv;
|
||||
}
|
||||
Integer i = 0;
|
||||
for (String st : s) {
|
||||
inv.setItem(i, it.get(st));
|
||||
i++;
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package gq.unurled.raxen.components.items.custom;
|
||||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
|
||||
public interface Item {
|
||||
|
||||
public void buildItem();
|
||||
|
||||
public void registerItem(Raxen main);
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package gq.unurled.raxen.components.items.custom;
|
||||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.items.custom.weapon.Dager;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class List {
|
||||
|
||||
private static Raxen main;
|
||||
|
||||
@Getter
|
||||
private java.util.List<Item> items;
|
||||
|
||||
public List(Raxen main) {
|
||||
this.main = main;
|
||||
this.items = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public void build() {
|
||||
// weapons
|
||||
items.add(new Dager());
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package gq.unurled.raxen.components.items.custom.weapon;
|
|||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.items.custom.Item;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
|
@ -16,10 +17,7 @@ import java.util.List;
|
|||
import static gq.unurled.raxen.components.items.NBT.*;
|
||||
import static gq.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
public class Dager {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
public class Dager implements Item {
|
||||
@Getter
|
||||
ItemStack dager;
|
||||
|
||||
|
@ -46,8 +44,8 @@ public class Dager {
|
|||
/**
|
||||
* need Raxen main to be set before calling this method.
|
||||
*/
|
||||
public void register() {
|
||||
@Override
|
||||
public void registerItem(Raxen main) {
|
||||
main.getManager().getItemManager().registerItem(dager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.raxen.utils.Items.listItemStackDeserialize;
|
||||
import static gq.unurled.raxen.utils.Items.setItemsToInventory;
|
||||
import static gq.unurled.raxen.utils.Items.*;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class PlayerConfig {
|
||||
|
@ -167,7 +166,7 @@ public class PlayerConfig {
|
|||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
if(playerDoc.getString("ec") != null) {
|
||||
debug(main, "Loading " + player.getName() + "'s storage.");
|
||||
ec = setItemsToInventory(listItemStackDeserialize(playerDoc.getString("ec")), ec);
|
||||
ec = setItemsToInventory(mapItemStackDeserialize(playerDoc.getString("ec")), ec);
|
||||
}
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
@ -195,12 +194,12 @@ public class PlayerConfig {
|
|||
config.getInt("luck"), config.getInt("itemLuck"));
|
||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
if((String) config.get("ec") != null) {
|
||||
ec = setItemsToInventory(listItemStackDeserialize((String) config.get("ec")), ec);
|
||||
ec = setItemsToInventory(mapItemStackDeserialize((String) config.get("ec")), ec);
|
||||
}
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
Inventory inv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||
PlayerInventory inv = (PlayerInventory) Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||
inv = setItemsToInventory(listItemStackDeserialize((String) config.getString("inv")), inv);
|
||||
player.getInventory().setContents(inv.getContents());
|
||||
player.updateInventory();
|
||||
|
@ -215,7 +214,8 @@ public class PlayerConfig {
|
|||
*/
|
||||
public void savePlayerConfig(@NotNull Player player) {
|
||||
Attributes attributes = new Attributes(main);
|
||||
Inventory inv = player.getInventory();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for(ItemStack it : inv) {
|
||||
|
@ -225,10 +225,7 @@ public class PlayerConfig {
|
|||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invstr= "";
|
||||
if (listInv.size() > 0) {
|
||||
invstr = Items.listItemStackSerialize(listInv);
|
||||
}
|
||||
String invstr= Items.itemStackSer(inv);
|
||||
debug(main, "saving...");
|
||||
String storage = sto.getConfig().getString("storage");
|
||||
Integer finalReverse = reverse;
|
||||
|
|
|
@ -3,6 +3,7 @@ package gq.unurled.raxen.manager.entity;
|
|||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.items.NBT;
|
||||
import gq.unurled.raxen.components.items.custom.Item;
|
||||
import gq.unurled.raxen.utils.Utils;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -34,6 +35,17 @@ public class ItemManager {
|
|||
public ItemManager(Raxen main) {
|
||||
this.main = main;
|
||||
// register();
|
||||
registerItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* register manually all item in Raxen
|
||||
*/
|
||||
private void registerItem() {
|
||||
gq.unurled.raxen.components.items.custom.List lisst = new gq.unurled.raxen.components.items.custom.List(main);
|
||||
for (Item items : lisst.getItems()) {
|
||||
items.registerItem(main);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@ import gq.unurled.raxen.Raxen;
|
|||
import gq.unurled.raxen.commands.RaxenCommand;
|
||||
import gq.unurled.raxen.commands.admin.*;
|
||||
import gq.unurled.raxen.commands.player.ClassCommand;
|
||||
import gq.unurled.raxen.commands.player.MainGuiCommand;
|
||||
import gq.unurled.raxen.commands.player.SkillsCommand;
|
||||
import gq.unurled.raxen.commands.player.StorageCommand;
|
||||
import lombok.Getter;
|
||||
|
@ -23,6 +24,7 @@ public class CommandManager {
|
|||
private SpawnEntity entityspawn;
|
||||
private ClassCommand classCommand;
|
||||
private CustomModelDataCommand customModelDataCommand;
|
||||
private MainGuiCommand mainGuiCommand;
|
||||
|
||||
public CommandManager(Raxen main) {
|
||||
this.main = main;
|
||||
|
@ -33,6 +35,7 @@ public class CommandManager {
|
|||
this.skillsCommand = new SkillsCommand(main);
|
||||
this.raxenCommand = new RaxenCommand(main);
|
||||
this.customModelDataCommand = new CustomModelDataCommand();
|
||||
this.mainGuiCommand = new MainGuiCommand(main);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +73,8 @@ public class CommandManager {
|
|||
main.getCommand("custommodeldata").setTabCompleter(customModelDataCommand);
|
||||
main.getCommand("custommodeldata").setExecutor(customModelDataCommand);
|
||||
|
||||
|
||||
main.getCommand("main_gui").setTabCompleter(mainGuiCommand);
|
||||
main.getCommand("main_gui").setExecutor(mainGuiCommand);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,7 +88,11 @@ public class Items {
|
|||
* @return a barrier block itemstack named close
|
||||
*/
|
||||
public static @NotNull ItemStack closeItem () {
|
||||
return createItem(Material.BARRIER, 1, false, false, colorString("<red>CLOSE"));
|
||||
ItemStack close = createItem(Material.BARRIER, 1, false, false, colorString("<red>CLOSE</red>"));
|
||||
ItemMeta clo = close.getItemMeta();
|
||||
clo.setCustomModelData(1);
|
||||
close.setItemMeta(clo);
|
||||
return close;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,12 +116,71 @@ public class Items {
|
|||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serelize the PlayerInventory
|
||||
* @param inv a player inventory
|
||||
* @return return a serelized string
|
||||
*/
|
||||
public static @NotNull String itemStackSer(PlayerInventory inv) {
|
||||
List<String> list = new ArrayList<>();
|
||||
Integer i = 0;
|
||||
for (ItemStack it : inv.getContents()) {
|
||||
String str = "";
|
||||
str = itemTo64(it);
|
||||
if (it != null) {
|
||||
if (isContained(it, inv.getArmorContents())) {
|
||||
str = str + "@#SLOT#" + getWhichArmor(it.getType());
|
||||
} else {
|
||||
i++;
|
||||
str = str + "@#SLOT#" + (i - 1);
|
||||
}
|
||||
}
|
||||
list.add(str);
|
||||
}
|
||||
return listItemStackSerialize(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* if item is in its
|
||||
* @param item an Itemstack
|
||||
* @param its an Itemstack[]
|
||||
* @return return if item is in its
|
||||
*/
|
||||
public static boolean isContained(ItemStack item, ItemStack[] its) {
|
||||
for (ItemStack it : its) {
|
||||
if (it == item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which armor the type is
|
||||
* @param type a material type
|
||||
* @return the armor type or null
|
||||
*/
|
||||
public static String getWhichArmor(Material type) {
|
||||
String name = type.name();
|
||||
if (name.contains("HELMET") || name.contains("helmet")) {
|
||||
return "HELMET";
|
||||
} else if (name.contains("CHESTPLATE") || name.contains("chestplate")) {
|
||||
return "CHESTPLATE";
|
||||
} else if (name.contains("LEGGINGS") || name.contains("leggins")) {
|
||||
return "LEGGINGS";
|
||||
} else if (name.contains("BOOTS") || name.contains("boots")) {
|
||||
return "BOOTS";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* a class that represent the itemstack deserialized.
|
||||
*/
|
||||
public static class itemStackDeserializeResult {
|
||||
int slot;
|
||||
ItemStack it;
|
||||
String armor;
|
||||
|
||||
/**
|
||||
* custructor
|
||||
|
@ -128,6 +191,12 @@ public class Items {
|
|||
this.slot = slot;
|
||||
this.it = it;
|
||||
}
|
||||
|
||||
public itemStackDeserializeResult(Integer slot, ItemStack it, String armor) {
|
||||
this.slot = slot;
|
||||
this.it = it;
|
||||
this.armor = armor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,6 +224,7 @@ public class Items {
|
|||
Gson gson = new Gson();
|
||||
ItemStack it = new ItemStack(Material.AIR);
|
||||
Integer slot = 0;
|
||||
String armor = null;
|
||||
debug("full item " + str);
|
||||
for (String s : mapp) {
|
||||
if(s != null) {
|
||||
|
@ -163,13 +233,22 @@ public class Items {
|
|||
} catch (Exception e) {
|
||||
if (!s.equals("")) {
|
||||
debug("slot " + s);
|
||||
slot = Integer.valueOf(s);
|
||||
try {
|
||||
slot = Integer.parseInt(s);
|
||||
} catch (NumberFormatException nfe) {
|
||||
armor = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
itemStackDeserializeResult itt = new itemStackDeserializeResult(slot, it);
|
||||
itemStackDeserializeResult itt;
|
||||
if (armor != null) {
|
||||
itt = new itemStackDeserializeResult(slot, it, armor);
|
||||
} else {
|
||||
itt = new itemStackDeserializeResult(slot, it);
|
||||
}
|
||||
return itt;
|
||||
}
|
||||
|
||||
|
@ -192,7 +271,7 @@ public class Items {
|
|||
* @param str a list of all serialized item
|
||||
* @return a list of itemstack with their slot
|
||||
*/
|
||||
public static @NotNull HashMap<Integer, ItemStack> listItemStackDeserialize(@NotNull String str) {
|
||||
public static @NotNull HashMap<Integer, ItemStack> mapItemStackDeserialize(@NotNull String str) {
|
||||
Gson gson = new Gson();
|
||||
List<String> map = Arrays.asList(str.split("@#NEW_ITEM#"));
|
||||
HashMap<Integer, ItemStack> inv = new HashMap<>();
|
||||
|
@ -214,6 +293,30 @@ public class Items {
|
|||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* deserialize item
|
||||
* @param str a list of all serialized item
|
||||
* @return a list of itemstack with their slot
|
||||
*/
|
||||
public static @NotNull List<itemStackDeserializeResult> listItemStackDeserialize(@NotNull String str) {
|
||||
Gson gson = new Gson();
|
||||
List<String> map = Arrays.asList(str.split("@#NEW_ITEM#"));
|
||||
List<itemStackDeserializeResult> inv = new ArrayList<>();
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for(String s : map) {
|
||||
ItemStack itt;
|
||||
Integer slot;
|
||||
if(s != null) {
|
||||
itemStackDeserializeResult itm = itemStackDeserilize(s);
|
||||
itt = itm.it;
|
||||
if (itt != null && itt.getType() != Material.AIR) {
|
||||
items.add(itt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* set all item in the list to their slot in inv
|
||||
* @param list a list of item with their slot
|
||||
|
@ -227,6 +330,37 @@ public class Items {
|
|||
return inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* set all item in the list to their slot in inv
|
||||
* @param list a list of item with their slot
|
||||
* @param inv the destined inventory
|
||||
* @return the inv
|
||||
*/
|
||||
public static PlayerInventory setItemsToInventory(@NotNull List<itemStackDeserializeResult> list, PlayerInventory inv) {
|
||||
Inventory invv = Bukkit.createInventory(null, 54);
|
||||
for (itemStackDeserializeResult itm : list) {
|
||||
if (itm.armor != null) {
|
||||
setArmorItem(inv, itm.it);
|
||||
} else {
|
||||
inv.setItem(itm.slot, itm.it);
|
||||
}
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static void setArmorItem(PlayerInventory inv, ItemStack item) {
|
||||
String name = item.getType().name();
|
||||
if (name.contains("HELMET")) {
|
||||
inv.setHelmet(item);
|
||||
} else if (name.contains("CHESTPLATE")) {
|
||||
inv.setChestplate(item);
|
||||
} else if (name.contains("LEGGINGS")) {
|
||||
inv.setLeggings(item);
|
||||
} else if (name.contains("BOOTS")) {
|
||||
inv.setBoots(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set all item in the list to their slot in inv
|
||||
* @param list a list of item with their slot
|
||||
|
|
|
@ -36,6 +36,8 @@ commands:
|
|||
- cmdata
|
||||
- cmd
|
||||
description: set custom model data to item
|
||||
main_gui:
|
||||
description: not very much used, more with right click on device
|
||||
|
||||
permissions:
|
||||
raxen.reload.cmd:
|
||||
|
@ -54,3 +56,5 @@ permissions:
|
|||
description: class command permission
|
||||
raxen.custommodeldata.cmd:
|
||||
description: custom model data command permission
|
||||
raxen.maingui.cmd:
|
||||
description: main gui command permission
|
Loading…
Reference in a new issue