This commit is contained in:
Ajneb97 2023-09-19 18:00:08 -03:00
parent 84ab6c8d96
commit 03f0e1446f
5 changed files with 23 additions and 5 deletions

View file

@ -203,6 +203,7 @@ public class KitsConfigManager {
String path = "actions."+actionType+"."+currentPos;
config.set(path+".action",kitAction.getAction());
config.set(path+".execute_before_items",kitAction.isExecuteBeforeItems());
config.set(path+".count_as_item",kitAction.isCountAsItem());
if(kitAction.getDisplayItem() != null){
kitItemManager.saveKitItemOnConfig(kitAction.getDisplayItem(),config,path+".display_item");
}
@ -287,10 +288,11 @@ public class KitsConfigManager {
for(String key : config.getConfigurationSection(mainPath+"actions."+actionType).getKeys(false)){
String path = mainPath+"actions."+actionType+"."+key;
String action = config.getString(path+".action");
boolean executeBeforeItem = config.contains("execute_before_items") ? config.getBoolean("execute_before_items") : false;
boolean executeBeforeItem = config.contains(path+".execute_before_items") ? config.getBoolean(path+".execute_before_items") : false;
boolean countAsItem = config.contains(path+".count_as_item") ? config.getBoolean(path+".count_as_item") : false;
KitItem item = config.contains(path+".display_item") ? kitItemManager.getKitItemFromConfig(config,path+".display_item") : null;
actions.add(new KitAction(action,item,executeBeforeItem));
actions.add(new KitAction(action,item,executeBeforeItem,countAsItem));
}
}
return actions;

View file

@ -266,6 +266,12 @@ public class KitsManager {
inventoryKitItems++;
}
ArrayList<KitAction> claimActions = kit.getClaimActions();
for(KitAction action : claimActions){
if(action.isCountAsItem()){
inventoryKitItems++;
}
}
boolean enoughSpace = freeSlots < inventoryKitItems;

View file

@ -132,7 +132,7 @@ public class InventoryEditActionsManager {
Kit kit = plugin.getKitsManager().getKitByName(inventoryPlayer.getKitName());
String type = inventoryPlayer.getInventoryName().replace("edit_chat_add_action_","");
ArrayList<KitAction> actions = getKitActionsFromType(kit,type);
actions.add(new KitAction(message,null,false));
actions.add(new KitAction(message,null,false,false));
inventoryEditManager.removeInventoryPlayer(inventoryPlayer.getPlayer());
openInventory(inventoryPlayer,type);

View file

@ -6,11 +6,13 @@ public class KitAction {
private String action;
private KitItem displayItem;
private boolean executeBeforeItems;
private boolean countAsItem;
public KitAction(String action, KitItem displayItem, boolean executeBeforeItems) {
public KitAction(String action, KitItem displayItem, boolean executeBeforeItems, boolean countAsItem) {
this.action = action;
this.displayItem = displayItem;
this.executeBeforeItems = executeBeforeItems;
this.countAsItem = countAsItem;
}
public String getAction() {
@ -36,4 +38,12 @@ public class KitAction {
public void setExecuteBeforeItems(boolean executeBeforeItems) {
this.executeBeforeItems = executeBeforeItems;
}
public boolean isCountAsItem() {
return countAsItem;
}
public void setCountAsItem(boolean countAsItem) {
this.countAsItem = countAsItem;
}
}

View file

@ -1,5 +1,5 @@
main: pk.ajneb97.PlayerKits2
version: 1.2.2
version: 1.3.1
name: PlayerKits2
api-version: 1.13
softdepend: [Vault,PlaceholderAPI]