1.10.1
This commit is contained in:
parent
7e2f561e2b
commit
0d9e82f4fd
13 changed files with 300 additions and 219 deletions
|
|
@ -110,7 +110,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||
sender.sendMessage(MessagesManager.getColoredMessage(" "));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit &8Opens the GUI."));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit claim <kit> &8Claims a kit outside the GUI."));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit create <kit> &8Creates a new kit using the items in your inventory."));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit create <kit> (optional)original &8Creates a new kit using the items in your inventory."));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit edit <kit> &8Edits a kit."));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit give <kit> <player> &8Gives a kit to a player."));
|
||||
sender.sendMessage(MessagesManager.getColoredMessage("&6/kit delete <kit> &8Deletes a kit."));
|
||||
|
|
@ -301,7 +301,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
public void create(Player player,String[] args,FileConfiguration messagesConfig,MessagesManager msgManager){
|
||||
// /kit create <kit>
|
||||
// /kit create <kit> (optional)<original>
|
||||
if(!PlayerUtils.isPlayerKitsAdmin(player)){
|
||||
msgManager.sendMessage(player,messagesConfig.getString("noPermissions"),true);
|
||||
return;
|
||||
|
|
@ -312,7 +312,12 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||
return;
|
||||
}
|
||||
|
||||
plugin.getKitsManager().createKit(args[1],player);
|
||||
boolean saveOriginalItems = false;
|
||||
if(args.length >= 3 && args[2].equalsIgnoreCase("original")){
|
||||
saveOriginalItems = true;
|
||||
}
|
||||
|
||||
plugin.getKitsManager().createKit(args[1],player,saveOriginalItems);
|
||||
}
|
||||
|
||||
public void delete(CommandSender sender,String[] args,FileConfiguration messagesConfig,MessagesManager msgManager){
|
||||
|
|
@ -409,6 +414,13 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||
|
||||
}
|
||||
}
|
||||
}else if(args.length == 3 && PlayerUtils.isPlayerKitsAdmin(sender)){
|
||||
if(args[0].equalsIgnoreCase("create")){
|
||||
if(args[2].isEmpty() || "original".startsWith(args[2].toLowerCase())) {
|
||||
completions.add("original");
|
||||
return completions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ public class KitsConfigManager {
|
|||
config.set("auto_armor",kit.isAutoArmor());
|
||||
config.set("permission_required",kit.isPermissionRequired());
|
||||
config.set("custom_permission",kit.getCustomPermission());
|
||||
config.set("save_original_items",kit.isSaveOriginalItems());
|
||||
|
||||
KitItemManager kitItemManager = plugin.getKitItemManager();
|
||||
int currentPos = 1;
|
||||
|
|
@ -233,6 +234,7 @@ public class KitsConfigManager {
|
|||
String customPermission = config.contains(mainPath+"custom_permission") ? config.getString(mainPath+"custom_permission") : null;
|
||||
boolean autoArmor = config.contains(mainPath+"auto_armor") ? config.getBoolean(mainPath+"auto_armor") : false;
|
||||
boolean oneTime = config.contains(mainPath+"one_time") ? config.getBoolean(mainPath+"one_time") : false;
|
||||
boolean saveOriginalItems = config.contains(mainPath+"save_original_items") ? config.getBoolean(mainPath+"save_original_items") : false;
|
||||
|
||||
ArrayList<KitItem> items = new ArrayList<KitItem>();
|
||||
if(config.contains(mainPath+"items")){
|
||||
|
|
@ -281,6 +283,7 @@ public class KitsConfigManager {
|
|||
kit.setDisplayItemOneTime(displayItemOneTime);
|
||||
kit.setDisplayItemOneTimeRequirements(displayItemOneTimeRequirements);
|
||||
kit.setRequirements(kitRequirements);
|
||||
kit.setSaveOriginalItems(saveOriginalItems);
|
||||
|
||||
return kit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ public class KitItemManager {
|
|||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public KitItem createKitItemFromItemStack(ItemStack item){
|
||||
public KitItem createKitItemFromItemStack(ItemStack item,boolean exactItem){
|
||||
if(exactItem){
|
||||
return new KitItem(item.clone());
|
||||
}
|
||||
|
||||
KitItem kitItem = new KitItem(item.getType().name());
|
||||
kitItem.setAmount(item.getAmount());
|
||||
|
||||
|
|
@ -119,7 +123,12 @@ public class KitItemManager {
|
|||
|
||||
return kitItem;
|
||||
}
|
||||
|
||||
public ItemStack createItemFromKitItem(KitItem kitItem,Player player){
|
||||
if(kitItem.getOriginalItem() != null){
|
||||
return kitItem.getOriginalItem().clone();
|
||||
}
|
||||
|
||||
ItemStack item = ItemUtils.createItemFromID(kitItem.getId());
|
||||
item.setAmount(kitItem.getAmount());
|
||||
|
||||
|
|
@ -240,95 +249,99 @@ public class KitItemManager {
|
|||
}
|
||||
|
||||
public void saveKitItemOnConfig(KitItem item,FileConfiguration config,String path){
|
||||
config.set(path+".id", item.getId());
|
||||
config.set(path+".name", item.getName());
|
||||
config.set(path+".amount", item.getAmount());
|
||||
if(item.getDurability() != 0) {
|
||||
config.set(path+".durability", item.getDurability());
|
||||
}
|
||||
if(item.getLore() != null && !item.getLore().isEmpty()) {
|
||||
config.set(path+".lore", item.getLore());
|
||||
}
|
||||
if(item.getEnchants() != null && !item.getEnchants().isEmpty()) {
|
||||
config.set(path+".enchants", item.getEnchants());
|
||||
}
|
||||
if(item.getFlags() != null && !item.getFlags().isEmpty()) {
|
||||
config.set(path+".item_flags", item.getFlags());
|
||||
}
|
||||
|
||||
if(item.getCustomModelData() != 0) {
|
||||
config.set(path+".custom_model_data", item.getCustomModelData());
|
||||
}
|
||||
if(item.getColor() != 0) {
|
||||
config.set(path+".color", item.getColor());
|
||||
}
|
||||
if(item.getNbt() != null && !item.getNbt().isEmpty()) {
|
||||
config.set(path+".nbt", item.getNbt());
|
||||
}
|
||||
if(item.getAttributes() != null && !item.getAttributes().isEmpty()) {
|
||||
config.set(path+".attributes", item.getAttributes());
|
||||
}
|
||||
if(item.getBookEnchants() != null && !item.getBookEnchants().isEmpty()) {
|
||||
config.set(path+".book_enchants", item.getBookEnchants());
|
||||
}
|
||||
if(item.getCanPlace() != null && !item.getCanPlace().isEmpty()) {
|
||||
config.set(path+".can_place", item.getCanPlace());
|
||||
}
|
||||
if(item.getCanDestroy() != null && !item.getCanDestroy().isEmpty()) {
|
||||
config.set(path+".can_destroy", item.getCanDestroy());
|
||||
}
|
||||
|
||||
KitItemSkullData skullData = item.getSkullData();
|
||||
if(skullData != null) {
|
||||
config.set(path+".skull_data.texture", skullData.getTexture());
|
||||
config.set(path+".skull_data.id", skullData.getId());
|
||||
config.set(path+".skull_data.owner", skullData.getOwner());
|
||||
}
|
||||
|
||||
KitItemPotionData potionData = item.getPotionData();
|
||||
if(potionData != null) {
|
||||
if(potionData.getPotionEffects() != null && !potionData.getPotionEffects().isEmpty()) {
|
||||
config.set(path+".potion_data.effects", potionData.getPotionEffects());
|
||||
if(item.getOriginalItem() != null){
|
||||
config.set(path+".original",item.getOriginalItem().clone());
|
||||
}else{
|
||||
config.set(path+".id", item.getId());
|
||||
config.set(path+".name", item.getName());
|
||||
config.set(path+".amount", item.getAmount());
|
||||
if(item.getDurability() != 0) {
|
||||
config.set(path+".durability", item.getDurability());
|
||||
}
|
||||
config.set(path+".potion_data.extended", potionData.isExtended());
|
||||
config.set(path+".potion_data.upgraded", potionData.isUpgraded());
|
||||
config.set(path+".potion_data.type", potionData.getPotionType());
|
||||
if(potionData.getPotionColor() != 0) {
|
||||
config.set(path+".potion_data.color", potionData.getPotionColor());
|
||||
if(item.getLore() != null && !item.getLore().isEmpty()) {
|
||||
config.set(path+".lore", item.getLore());
|
||||
}
|
||||
}
|
||||
|
||||
KitItemFireworkData fireworkData = item.getFireworkData();
|
||||
if(fireworkData != null) {
|
||||
if(fireworkData.getFireworkRocketEffects() != null && !fireworkData.getFireworkRocketEffects().isEmpty()) {
|
||||
config.set(path+".firework_data.rocket_effects", fireworkData.getFireworkRocketEffects());
|
||||
if(item.getEnchants() != null && !item.getEnchants().isEmpty()) {
|
||||
config.set(path+".enchants", item.getEnchants());
|
||||
}
|
||||
config.set(path+".firework_data.star_effect", fireworkData.getFireworkStarEffect());
|
||||
if(fireworkData.getFireworkPower() != 0) {
|
||||
config.set(path+".firework_data.power", fireworkData.getFireworkPower());
|
||||
if(item.getFlags() != null && !item.getFlags().isEmpty()) {
|
||||
config.set(path+".item_flags", item.getFlags());
|
||||
}
|
||||
}
|
||||
|
||||
KitItemBannerData bannerData = item.getBannerData();
|
||||
if(bannerData != null) {
|
||||
if(bannerData.getPatterns() != null && !bannerData.getPatterns().isEmpty()) {
|
||||
config.set(path+".banner_data.patterns", bannerData.getPatterns());
|
||||
if(item.getCustomModelData() != 0) {
|
||||
config.set(path+".custom_model_data", item.getCustomModelData());
|
||||
}
|
||||
if(item.getColor() != 0) {
|
||||
config.set(path+".color", item.getColor());
|
||||
}
|
||||
if(item.getNbt() != null && !item.getNbt().isEmpty()) {
|
||||
config.set(path+".nbt", item.getNbt());
|
||||
}
|
||||
if(item.getAttributes() != null && !item.getAttributes().isEmpty()) {
|
||||
config.set(path+".attributes", item.getAttributes());
|
||||
}
|
||||
if(item.getBookEnchants() != null && !item.getBookEnchants().isEmpty()) {
|
||||
config.set(path+".book_enchants", item.getBookEnchants());
|
||||
}
|
||||
if(item.getCanPlace() != null && !item.getCanPlace().isEmpty()) {
|
||||
config.set(path+".can_place", item.getCanPlace());
|
||||
}
|
||||
if(item.getCanDestroy() != null && !item.getCanDestroy().isEmpty()) {
|
||||
config.set(path+".can_destroy", item.getCanDestroy());
|
||||
}
|
||||
config.set(path+".banner_data.base_color", bannerData.getBaseColor());
|
||||
}
|
||||
|
||||
KitItemBookData bookData = item.getBookData();
|
||||
if(bookData != null) {
|
||||
config.set(path+".book_data.author", bookData.getAuthor());
|
||||
config.set(path+".book_data.title", bookData.getTitle());
|
||||
config.set(path+".book_data.pages", bookData.getPages());
|
||||
config.set(path+".book_data.generation", bookData.getGeneration());
|
||||
}
|
||||
KitItemSkullData skullData = item.getSkullData();
|
||||
if(skullData != null) {
|
||||
config.set(path+".skull_data.texture", skullData.getTexture());
|
||||
config.set(path+".skull_data.id", skullData.getId());
|
||||
config.set(path+".skull_data.owner", skullData.getOwner());
|
||||
}
|
||||
|
||||
KitItemTrimData trimData = item.getTrimData();
|
||||
if(trimData != null){
|
||||
config.set(path+".trim_data.pattern", trimData.getPattern());
|
||||
config.set(path+".trim_data.material", trimData.getMaterial());
|
||||
KitItemPotionData potionData = item.getPotionData();
|
||||
if(potionData != null) {
|
||||
if(potionData.getPotionEffects() != null && !potionData.getPotionEffects().isEmpty()) {
|
||||
config.set(path+".potion_data.effects", potionData.getPotionEffects());
|
||||
}
|
||||
config.set(path+".potion_data.extended", potionData.isExtended());
|
||||
config.set(path+".potion_data.upgraded", potionData.isUpgraded());
|
||||
config.set(path+".potion_data.type", potionData.getPotionType());
|
||||
if(potionData.getPotionColor() != 0) {
|
||||
config.set(path+".potion_data.color", potionData.getPotionColor());
|
||||
}
|
||||
}
|
||||
|
||||
KitItemFireworkData fireworkData = item.getFireworkData();
|
||||
if(fireworkData != null) {
|
||||
if(fireworkData.getFireworkRocketEffects() != null && !fireworkData.getFireworkRocketEffects().isEmpty()) {
|
||||
config.set(path+".firework_data.rocket_effects", fireworkData.getFireworkRocketEffects());
|
||||
}
|
||||
config.set(path+".firework_data.star_effect", fireworkData.getFireworkStarEffect());
|
||||
if(fireworkData.getFireworkPower() != 0) {
|
||||
config.set(path+".firework_data.power", fireworkData.getFireworkPower());
|
||||
}
|
||||
}
|
||||
|
||||
KitItemBannerData bannerData = item.getBannerData();
|
||||
if(bannerData != null) {
|
||||
if(bannerData.getPatterns() != null && !bannerData.getPatterns().isEmpty()) {
|
||||
config.set(path+".banner_data.patterns", bannerData.getPatterns());
|
||||
}
|
||||
config.set(path+".banner_data.base_color", bannerData.getBaseColor());
|
||||
}
|
||||
|
||||
KitItemBookData bookData = item.getBookData();
|
||||
if(bookData != null) {
|
||||
config.set(path+".book_data.author", bookData.getAuthor());
|
||||
config.set(path+".book_data.title", bookData.getTitle());
|
||||
config.set(path+".book_data.pages", bookData.getPages());
|
||||
config.set(path+".book_data.generation", bookData.getGeneration());
|
||||
}
|
||||
|
||||
KitItemTrimData trimData = item.getTrimData();
|
||||
if(trimData != null){
|
||||
config.set(path+".trim_data.pattern", trimData.getPattern());
|
||||
config.set(path+".trim_data.material", trimData.getMaterial());
|
||||
}
|
||||
}
|
||||
|
||||
if(item.isOffhand()){
|
||||
|
|
@ -340,140 +353,144 @@ public class KitItemManager {
|
|||
}
|
||||
|
||||
public KitItem getKitItemFromConfig(FileConfiguration config, String path){
|
||||
String id = config.getString(path+".id");
|
||||
String name = config.contains(path+".name") ? config.getString(path+".name") : null;
|
||||
List<String> lore = config.contains(path+".lore") ? config.getStringList(path+".lore") : null;
|
||||
int amount = config.contains(path+".amount") ? config.getInt(path+".amount") : 1;
|
||||
short durability = config.contains(path+".durability") ? (short) config.getInt(path+".durability") : 0;
|
||||
int customModelData = config.contains(path+".custom_model_data") ? config.getInt(path+".custom_model_data") : 0;
|
||||
int color = config.contains(path+".color") ? config.getInt(path+".color") : 0;
|
||||
List<String> enchants = config.contains(path+".enchants") ? config.getStringList(path+".enchants") : null;
|
||||
List<String> flags = config.contains(path+".item_flags") ? config.getStringList(path+".item_flags") : null;
|
||||
List<String> bookEnchants = config.contains(path+".book_enchants") ? config.getStringList(path+".book_enchants") : null;
|
||||
List<String> nbtList = config.contains(path+".nbt") ? config.getStringList(path+".nbt") : null;
|
||||
List<String> attributes = config.contains(path+".attributes") ? config.getStringList(path+".attributes") : null;
|
||||
List<String> canPlace = config.contains(path+".can_place") ? config.getStringList(path+".can_place") : null;
|
||||
List<String> canDestroy = config.contains(path+".can_destroy") ? config.getStringList(path+".can_destroy") : null;
|
||||
|
||||
boolean offhand = config.contains(path+".offhand") ? config.getBoolean(path+".offhand") : false;
|
||||
int previewSlot = config.contains(path+".preview_slot") ? config.getInt(path+".preview_slot") : -1;
|
||||
KitItem kitItem = null;
|
||||
if(config.contains(path+".original")){
|
||||
kitItem = new KitItem(config.getItemStack(path+".original"));
|
||||
}else{
|
||||
String id = config.getString(path+".id");
|
||||
String name = config.contains(path+".name") ? config.getString(path+".name") : null;
|
||||
List<String> lore = config.contains(path+".lore") ? config.getStringList(path+".lore") : null;
|
||||
int amount = config.contains(path+".amount") ? config.getInt(path+".amount") : 1;
|
||||
short durability = config.contains(path+".durability") ? (short) config.getInt(path+".durability") : 0;
|
||||
int customModelData = config.contains(path+".custom_model_data") ? config.getInt(path+".custom_model_data") : 0;
|
||||
int color = config.contains(path+".color") ? config.getInt(path+".color") : 0;
|
||||
List<String> enchants = config.contains(path+".enchants") ? config.getStringList(path+".enchants") : null;
|
||||
List<String> flags = config.contains(path+".item_flags") ? config.getStringList(path+".item_flags") : null;
|
||||
List<String> bookEnchants = config.contains(path+".book_enchants") ? config.getStringList(path+".book_enchants") : null;
|
||||
List<String> nbtList = config.contains(path+".nbt") ? config.getStringList(path+".nbt") : null;
|
||||
List<String> attributes = config.contains(path+".attributes") ? config.getStringList(path+".attributes") : null;
|
||||
List<String> canPlace = config.contains(path+".can_place") ? config.getStringList(path+".can_place") : null;
|
||||
List<String> canDestroy = config.contains(path+".can_destroy") ? config.getStringList(path+".can_destroy") : null;
|
||||
|
||||
KitItemSkullData skullData = null;
|
||||
if(config.contains(path+".skull_data")) {
|
||||
String skullTexture = null;
|
||||
String skullId = null;
|
||||
String skullOwner = null;
|
||||
if(config.contains(path+".skull_data.texture")) {
|
||||
skullTexture = config.getString(path+".skull_data.texture");
|
||||
KitItemSkullData skullData = null;
|
||||
if(config.contains(path+".skull_data")) {
|
||||
String skullTexture = null;
|
||||
String skullId = null;
|
||||
String skullOwner = null;
|
||||
if(config.contains(path+".skull_data.texture")) {
|
||||
skullTexture = config.getString(path+".skull_data.texture");
|
||||
}
|
||||
if(config.contains(path+".skull_data.id")) {
|
||||
skullId = config.getString(path+".skull_data.id");
|
||||
}
|
||||
if(config.contains(path+".skull_data.owner")) {
|
||||
skullOwner = config.getString(path+".skull_data.owner");
|
||||
}
|
||||
skullData = new KitItemSkullData(skullOwner,skullTexture,skullId);
|
||||
}
|
||||
if(config.contains(path+".skull_data.id")) {
|
||||
skullId = config.getString(path+".skull_data.id");
|
||||
KitItemPotionData potionData = null;
|
||||
if(config.contains(path+".potion_data")) {
|
||||
List<String> potionEffects = null;
|
||||
boolean extended = false;
|
||||
boolean upgraded = false;
|
||||
String potionType = null;
|
||||
int potionColor = 0;
|
||||
if(config.contains(path+".potion_data.effects")) {
|
||||
potionEffects = config.getStringList(path+".potion_data.effects");
|
||||
}
|
||||
if(config.contains(path+".potion_data.extended")) {
|
||||
extended = config.getBoolean(path+".potion_data.extended");
|
||||
}
|
||||
if(config.contains(path+".potion_data.upgraded")) {
|
||||
upgraded = config.getBoolean(path+".potion_data.upgraded");
|
||||
}
|
||||
if(config.contains(path+".potion_data.type")) {
|
||||
potionType = config.getString(path+".potion_data.type");
|
||||
}
|
||||
if(config.contains(path+".potion_data.color")) {
|
||||
potionColor = config.getInt(path+".potion_data.color");
|
||||
}
|
||||
|
||||
potionData = new KitItemPotionData(upgraded,extended,potionType,potionColor,potionEffects);
|
||||
}
|
||||
if(config.contains(path+".skull_data.owner")) {
|
||||
skullOwner = config.getString(path+".skull_data.owner");
|
||||
KitItemFireworkData fireworkData = null;
|
||||
if(config.contains(path+".firework_data")) {
|
||||
List<String> rocketEffects = null;
|
||||
String starEffect = null;
|
||||
int power = 0;
|
||||
if(config.contains(path+".firework_data.rocket_effects")) {
|
||||
rocketEffects = config.getStringList(path+".firework_data.rocket_effects");
|
||||
}
|
||||
if(config.contains(path+".firework_data.star_effect")) {
|
||||
starEffect = config.getString(path+".firework_data.star_effect");
|
||||
}
|
||||
if(config.contains(path+".firework_data.power")) {
|
||||
power = config.getInt(path+".firework_data.power");
|
||||
}
|
||||
|
||||
fireworkData = new KitItemFireworkData(rocketEffects,starEffect,power);
|
||||
}
|
||||
skullData = new KitItemSkullData(skullOwner,skullTexture,skullId);
|
||||
}
|
||||
KitItemPotionData potionData = null;
|
||||
if(config.contains(path+".potion_data")) {
|
||||
List<String> potionEffects = null;
|
||||
boolean extended = false;
|
||||
boolean upgraded = false;
|
||||
String potionType = null;
|
||||
int potionColor = 0;
|
||||
if(config.contains(path+".potion_data.effects")) {
|
||||
potionEffects = config.getStringList(path+".potion_data.effects");
|
||||
KitItemBannerData bannerData = null;
|
||||
if(config.contains(path+".banner_data")) {
|
||||
List<String> patterns = null;
|
||||
String baseColor = null;
|
||||
if(config.contains(path+".banner_data.patterns")) {
|
||||
patterns = config.getStringList(path+".banner_data.patterns");
|
||||
}
|
||||
if(config.contains(path+".banner_data.base_color")) {
|
||||
baseColor = config.getString(path+".banner_data.base_color");
|
||||
}
|
||||
|
||||
bannerData = new KitItemBannerData(patterns,baseColor);
|
||||
}
|
||||
if(config.contains(path+".potion_data.extended")) {
|
||||
extended = config.getBoolean(path+".potion_data.extended");
|
||||
KitItemBookData bookData = null;
|
||||
if(config.contains(path+".book_data")) {
|
||||
List<String> pages = config.getStringList(path+".book_data.pages");
|
||||
String author = null;
|
||||
String generation = null;
|
||||
String title = null;
|
||||
if(config.contains(path+".book_data.author")) {
|
||||
author = config.getString(path+".book_data.author");
|
||||
}
|
||||
if(config.contains(path+".book_data.generation")) {
|
||||
generation = config.getString(path+".book_data.generation");
|
||||
}
|
||||
if(config.contains(path+".book_data.title")) {
|
||||
title = config.getString(path+".book_data.title");
|
||||
}
|
||||
|
||||
bookData = new KitItemBookData(pages,author,generation,title);
|
||||
}
|
||||
if(config.contains(path+".potion_data.upgraded")) {
|
||||
upgraded = config.getBoolean(path+".potion_data.upgraded");
|
||||
}
|
||||
if(config.contains(path+".potion_data.type")) {
|
||||
potionType = config.getString(path+".potion_data.type");
|
||||
}
|
||||
if(config.contains(path+".potion_data.color")) {
|
||||
potionColor = config.getInt(path+".potion_data.color");
|
||||
KitItemTrimData trimData = null;
|
||||
if(config.contains(path+".trim_data")){
|
||||
String material = config.getString(path+".trim_data.material");
|
||||
String pattern = config.getString(path+".trim_data.pattern");
|
||||
trimData = new KitItemTrimData(pattern,material);
|
||||
}
|
||||
|
||||
potionData = new KitItemPotionData(upgraded,extended,potionType,potionColor,potionEffects);
|
||||
kitItem = new KitItem(id);
|
||||
kitItem.setName(name);
|
||||
kitItem.setLore(lore);
|
||||
kitItem.setAmount(amount);
|
||||
kitItem.setDurability(durability);
|
||||
kitItem.setCustomModelData(customModelData);
|
||||
kitItem.setColor(color);
|
||||
kitItem.setEnchants(enchants);
|
||||
kitItem.setFlags(flags);
|
||||
kitItem.setBookEnchants(bookEnchants);
|
||||
kitItem.setNbt(nbtList);
|
||||
kitItem.setAttributes(attributes);
|
||||
kitItem.setCanPlace(canPlace);
|
||||
kitItem.setCanDestroy(canDestroy);
|
||||
kitItem.setSkullData(skullData);
|
||||
kitItem.setPotionData(potionData);
|
||||
kitItem.setFireworkData(fireworkData);
|
||||
kitItem.setBannerData(bannerData);
|
||||
kitItem.setBookData(bookData);
|
||||
kitItem.setTrimData(trimData);
|
||||
}
|
||||
KitItemFireworkData fireworkData = null;
|
||||
if(config.contains(path+".firework_data")) {
|
||||
List<String> rocketEffects = null;
|
||||
String starEffect = null;
|
||||
int power = 0;
|
||||
if(config.contains(path+".firework_data.rocket_effects")) {
|
||||
rocketEffects = config.getStringList(path+".firework_data.rocket_effects");
|
||||
}
|
||||
if(config.contains(path+".firework_data.star_effect")) {
|
||||
starEffect = config.getString(path+".firework_data.star_effect");
|
||||
}
|
||||
if(config.contains(path+".firework_data.power")) {
|
||||
power = config.getInt(path+".firework_data.power");
|
||||
}
|
||||
|
||||
fireworkData = new KitItemFireworkData(rocketEffects,starEffect,power);
|
||||
}
|
||||
KitItemBannerData bannerData = null;
|
||||
if(config.contains(path+".banner_data")) {
|
||||
List<String> patterns = null;
|
||||
String baseColor = null;
|
||||
if(config.contains(path+".banner_data.patterns")) {
|
||||
patterns = config.getStringList(path+".banner_data.patterns");
|
||||
}
|
||||
if(config.contains(path+".banner_data.base_color")) {
|
||||
baseColor = config.getString(path+".banner_data.base_color");
|
||||
}
|
||||
|
||||
bannerData = new KitItemBannerData(patterns,baseColor);
|
||||
}
|
||||
KitItemBookData bookData = null;
|
||||
if(config.contains(path+".book_data")) {
|
||||
List<String> pages = config.getStringList(path+".book_data.pages");
|
||||
String author = null;
|
||||
String generation = null;
|
||||
String title = null;
|
||||
if(config.contains(path+".book_data.author")) {
|
||||
author = config.getString(path+".book_data.author");
|
||||
}
|
||||
if(config.contains(path+".book_data.generation")) {
|
||||
generation = config.getString(path+".book_data.generation");
|
||||
}
|
||||
if(config.contains(path+".book_data.title")) {
|
||||
title = config.getString(path+".book_data.title");
|
||||
}
|
||||
|
||||
bookData = new KitItemBookData(pages,author,generation,title);
|
||||
}
|
||||
KitItemTrimData trimData = null;
|
||||
if(config.contains(path+".trim_data")){
|
||||
String material = config.getString(path+".trim_data.material");
|
||||
String pattern = config.getString(path+".trim_data.pattern");
|
||||
trimData = new KitItemTrimData(pattern,material);
|
||||
}
|
||||
|
||||
KitItem kitItem = new KitItem(id);
|
||||
kitItem.setName(name);
|
||||
kitItem.setLore(lore);
|
||||
kitItem.setAmount(amount);
|
||||
kitItem.setDurability(durability);
|
||||
kitItem.setCustomModelData(customModelData);
|
||||
kitItem.setColor(color);
|
||||
kitItem.setEnchants(enchants);
|
||||
kitItem.setFlags(flags);
|
||||
kitItem.setBookEnchants(bookEnchants);
|
||||
kitItem.setNbt(nbtList);
|
||||
kitItem.setAttributes(attributes);
|
||||
kitItem.setCanPlace(canPlace);
|
||||
kitItem.setCanDestroy(canDestroy);
|
||||
kitItem.setSkullData(skullData);
|
||||
kitItem.setPotionData(potionData);
|
||||
kitItem.setFireworkData(fireworkData);
|
||||
kitItem.setBannerData(bannerData);
|
||||
kitItem.setBookData(bookData);
|
||||
kitItem.setTrimData(trimData);
|
||||
|
||||
kitItem.setOffhand(offhand);
|
||||
kitItem.setPreviewSlot(previewSlot);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class KitsManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void createKit(String kitName,Player player){
|
||||
public void createKit(String kitName,Player player,boolean saveOriginalItems){
|
||||
Kit kit = getKitByName(kitName);
|
||||
FileConfiguration messagesFile = plugin.getConfigsManager().getMessagesConfigManager().getConfig();
|
||||
MainConfigManager mainConfigManager = plugin.getConfigsManager().getMainConfigManager();
|
||||
|
|
@ -86,7 +86,7 @@ public class KitsManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
KitItem kitItem = kitItemManager.createKitItemFromItemStack(item);
|
||||
KitItem kitItem = kitItemManager.createKitItemFromItemStack(item,saveOriginalItems);
|
||||
|
||||
//Check for armor/offhand
|
||||
if(i >= 36 && i<=39){
|
||||
|
|
@ -109,6 +109,7 @@ public class KitsManager {
|
|||
kit.setItems(items);
|
||||
kit.setDefaults(mainConfigManager.getNewKitDefault());
|
||||
kit.setAutoArmor(hasArmor);
|
||||
kit.setSaveOriginalItems(saveOriginalItems);
|
||||
|
||||
kits.add(kit);
|
||||
plugin.getConfigsManager().getKitsConfigManager().saveConfig(kit);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class PlayerDataManager {
|
|||
|
||||
public PlayerData getPlayerByName(String name){
|
||||
for(PlayerData player : players){
|
||||
if(player.getName().equals(name)){
|
||||
if(player.getName() != null && player.getName().equals(name)){
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ public class PlayerDataManager {
|
|||
playerData.setModified(true);
|
||||
players.add(playerData);
|
||||
}else{
|
||||
if(!playerData.getName().equals(player.getName())){
|
||||
if(playerData.getName() == null || !playerData.getName().equals(player.getName())){
|
||||
playerData.setName(player.getName());
|
||||
playerData.setModified(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,9 @@ public class VerifyManager {
|
|||
}
|
||||
for(KitItem kitItem : allKitItems){
|
||||
if(kitItem != null){
|
||||
if(kitItem.getOriginalItem() != null){
|
||||
continue;
|
||||
}
|
||||
if(!verifyItem(kitItem.getId())){
|
||||
errors.add(new PKInvalidItem(kit.getName()+".yml",null,true,kitItem.getId()));
|
||||
criticalErrors = true;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class InventoryEditDisplayManager {
|
|||
|
||||
KitItem kitItem = null;
|
||||
if(item != null && !item.getType().equals(Material.AIR)){
|
||||
kitItem = plugin.getKitItemManager().createKitItemFromItemStack(item);
|
||||
kitItem = plugin.getKitItemManager().createKitItemFromItemStack(item,false);
|
||||
}
|
||||
|
||||
Kit kit = plugin.getKitsManager().getKitByName(inventoryPlayer.getKitName());
|
||||
|
|
|
|||
|
|
@ -159,12 +159,12 @@ public class InventoryEditKitItemsManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
KitItem kitItem = kitItemManager.createKitItemFromItemStack(item);
|
||||
KitItem kitItem = kitItemManager.createKitItemFromItemStack(item,kit.isSaveOriginalItems());
|
||||
//Check offhand
|
||||
String offhand = ItemUtils.getTagStringItem(plugin,item,"playerkits_offhand");
|
||||
if(offhand != null){
|
||||
kitItem.setOffhand(true);
|
||||
kitItem.removeOffHandFromEditInventory();
|
||||
kitItem.removeOffHandFromEditInventory(plugin);
|
||||
}
|
||||
|
||||
//Preview position
|
||||
|
|
|
|||
|
|
@ -215,7 +215,12 @@ public class InventoryEditManager {
|
|||
lore.add("&7Current Items:");
|
||||
int max = 20;
|
||||
for(KitItem kitItem : kit.getItems()){
|
||||
lore.add(MessagesManager.getColoredMessage("&8- &fx"+kitItem.getAmount()+" "+kitItem.getId()));
|
||||
if(kitItem.getOriginalItem() != null){
|
||||
ItemStack originalItem = kitItem.getOriginalItem();
|
||||
lore.add(MessagesManager.getColoredMessage("&8- &fx"+originalItem.getAmount()+" "+originalItem.getType()));
|
||||
}else{
|
||||
lore.add(MessagesManager.getColoredMessage("&8- &fx"+kitItem.getAmount()+" "+kitItem.getId()));
|
||||
}
|
||||
max--;
|
||||
if(max <= 0){
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public class Kit {
|
|||
private ArrayList<KitItem> items;
|
||||
private ArrayList<KitAction> claimActions;
|
||||
private ArrayList<KitAction> errorActions;
|
||||
private boolean saveOriginalItems;
|
||||
|
||||
private KitItem displayItemDefault;
|
||||
private KitItem displayItemNoPermission;
|
||||
|
|
@ -31,6 +32,7 @@ public class Kit {
|
|||
this.cooldown = 0;
|
||||
this.autoArmor = false;
|
||||
this.oneTime = false;
|
||||
this.saveOriginalItems = false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -154,6 +156,14 @@ public class Kit {
|
|||
this.customPermission = customPermission;
|
||||
}
|
||||
|
||||
public boolean isSaveOriginalItems() {
|
||||
return saveOriginalItems;
|
||||
}
|
||||
|
||||
public void setSaveOriginalItems(boolean saveOriginalItems) {
|
||||
this.saveOriginalItems = saveOriginalItems;
|
||||
}
|
||||
|
||||
public boolean playerHasPermission(CommandSender player){
|
||||
if(permissionRequired){
|
||||
if(customPermission != null){
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package pk.ajneb97.model.item;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import pk.ajneb97.PlayerKits2;
|
||||
import pk.ajneb97.utils.ItemUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -34,6 +39,8 @@ public class KitItem{
|
|||
private boolean offhand;
|
||||
private int previewSlot;
|
||||
|
||||
private ItemStack originalItem;
|
||||
|
||||
public KitItem(String id) {
|
||||
this.id = id;
|
||||
this.amount = 1;
|
||||
|
|
@ -43,6 +50,19 @@ public class KitItem{
|
|||
this.previewSlot = -1;
|
||||
}
|
||||
|
||||
public KitItem(ItemStack item){
|
||||
this.previewSlot = -1;
|
||||
this.originalItem = item;
|
||||
}
|
||||
|
||||
public ItemStack getOriginalItem() {
|
||||
return originalItem;
|
||||
}
|
||||
|
||||
public void setOriginalItem(ItemStack originalItem) {
|
||||
this.originalItem = originalItem;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -219,8 +239,18 @@ public class KitItem{
|
|||
this.previewSlot = previewSlot;
|
||||
}
|
||||
|
||||
public void removeOffHandFromEditInventory(){
|
||||
public void removeOffHandFromEditInventory(PlayerKits2 plugin){
|
||||
//Assumes that has the lore and the nbt
|
||||
if(originalItem != null){
|
||||
ItemMeta meta = originalItem.getItemMeta();
|
||||
List<String> lore = meta.getLore();
|
||||
lore.remove(lore.size()-1);
|
||||
lore.remove(lore.size()-1);
|
||||
meta.setLore(lore);
|
||||
originalItem.setItemMeta(meta);
|
||||
originalItem = ItemUtils.removeTagItem(plugin,originalItem,"playerkits_offhand");
|
||||
return;
|
||||
}
|
||||
lore.remove(lore.size()-1);
|
||||
lore.remove(lore.size()-1);
|
||||
for(int i=0;i<nbt.size();i++){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ commandGiveError: "&cYou need to use: &7/kit give <kit> <player>"
|
|||
commandGiveError2: "&cThere was an error giving the kit: &7%error%"
|
||||
commandGiveCorrect: "&aKit &7%kit% &agiven to &e%player%&a!"
|
||||
commandClaimError: "&cYou need to use: &7/kit claim <kit>"
|
||||
commandCreateError: "&cYou need to use: &7/kit create <name>"
|
||||
commandCreateError: "&cYou need to use: &7/kit create <name> (optional)original"
|
||||
commandDeleteError: "&cYou need to use: &7/kit delete <name>"
|
||||
commandResetError: "&cYou need to use: &7/kit reset <kit> <player>"
|
||||
commandEditError: "&cYou need to use: &7/kit edit <kit>"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
main: pk.ajneb97.PlayerKits2
|
||||
version: 1.9.4
|
||||
version: 1.10.1
|
||||
name: PlayerKits2
|
||||
api-version: 1.13
|
||||
softdepend: [Vault,PlaceholderAPI]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue