1.17.1
This commit is contained in:
parent
dfd0cd597f
commit
151a8d011d
10 changed files with 138 additions and 147 deletions
|
|
@ -7,11 +7,6 @@ import pk.ajneb97.model.inventory.ItemKitInventory;
|
||||||
import pk.ajneb97.model.inventory.KitInventory;
|
import pk.ajneb97.model.inventory.KitInventory;
|
||||||
import pk.ajneb97.model.item.KitItem;
|
import pk.ajneb97.model.item.KitItem;
|
||||||
import pk.ajneb97.utils.OtherUtils;
|
import pk.ajneb97.utils.OtherUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -28,6 +23,7 @@ public class InventoryConfigManager {
|
||||||
if(this.configFile.isFirstTime() && OtherUtils.isLegacy()){
|
if(this.configFile.isFirstTime() && OtherUtils.isLegacy()){
|
||||||
checkAndFix();
|
checkAndFix();
|
||||||
}
|
}
|
||||||
|
checkClickCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkAndFix(){
|
public void checkAndFix(){
|
||||||
|
|
@ -39,6 +35,38 @@ public class InventoryConfigManager {
|
||||||
configFile.saveConfig();
|
configFile.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkClickCommands(){
|
||||||
|
boolean needsSave = false;
|
||||||
|
FileConfiguration config = configFile.getConfig();
|
||||||
|
if(config.contains("inventories")) {
|
||||||
|
for (String key : config.getConfigurationSection("inventories").getKeys(false)) {
|
||||||
|
for(String slotString : config.getConfigurationSection("inventories."+key).getKeys(false)) {
|
||||||
|
String path = "inventories."+key+"."+slotString;
|
||||||
|
if(config.contains(path+".click_commands")){
|
||||||
|
List<String> clickActions = new ArrayList<>();
|
||||||
|
List<String> clickCommands = config.getStringList(path+".click_commands");
|
||||||
|
for(String c : clickCommands){
|
||||||
|
if(c.startsWith("msg %player% ")) {
|
||||||
|
String text = c.replace("msg %player% ", "");
|
||||||
|
clickActions.add("message: "+text);
|
||||||
|
}else if(c.equals("close_inventory")){
|
||||||
|
clickActions.add(c);
|
||||||
|
}else{
|
||||||
|
clickActions.add("console_command: "+c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
config.set(path+".click_actions",clickActions);
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(needsSave){
|
||||||
|
configFile.saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void configure(){
|
public void configure(){
|
||||||
FileConfiguration config = configFile.getConfig();
|
FileConfiguration config = configFile.getConfig();
|
||||||
|
|
||||||
|
|
@ -46,7 +74,7 @@ public class InventoryConfigManager {
|
||||||
KitItemManager kitItemManager = plugin.getKitItemManager();
|
KitItemManager kitItemManager = plugin.getKitItemManager();
|
||||||
if(config.contains("inventories")) {
|
if(config.contains("inventories")) {
|
||||||
for(String key : config.getConfigurationSection("inventories").getKeys(false)) {
|
for(String key : config.getConfigurationSection("inventories").getKeys(false)) {
|
||||||
int slots = Integer.valueOf(config.getString("inventories."+key+".slots"));
|
int slots = config.getInt("inventories."+key+".slots");
|
||||||
String title = config.getString("inventories."+key+".title");
|
String title = config.getString("inventories."+key+".title");
|
||||||
|
|
||||||
List<ItemKitInventory> items = new ArrayList<>();
|
List<ItemKitInventory> items = new ArrayList<>();
|
||||||
|
|
@ -61,13 +89,13 @@ public class InventoryConfigManager {
|
||||||
String openInventory = config.contains(path+".open_inventory") ?
|
String openInventory = config.contains(path+".open_inventory") ?
|
||||||
config.getString(path+".open_inventory") : null;
|
config.getString(path+".open_inventory") : null;
|
||||||
|
|
||||||
List<String> commands = config.contains(path+".click_commands") ?
|
List<String> clickActions = config.contains(path+".click_actions") ?
|
||||||
config.getStringList(path+".click_commands") : null;
|
config.getStringList(path+".click_actions") : null;
|
||||||
|
|
||||||
String type = config.contains(path+".type") ?
|
String type = config.contains(path+".type") ?
|
||||||
config.getString(path+".type") : null;
|
config.getString(path+".type") : null;
|
||||||
|
|
||||||
ItemKitInventory itemCraft = new ItemKitInventory(slotString,item,openInventory,commands,type);
|
ItemKitInventory itemCraft = new ItemKitInventory(slotString,item,openInventory,clickActions,type);
|
||||||
items.add(itemCraft);
|
items.add(itemCraft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,8 +136,8 @@ public class InventoryConfigManager {
|
||||||
if(item.getOpenInventory() != null){
|
if(item.getOpenInventory() != null){
|
||||||
config.set(path+".open_inventory",item.getOpenInventory());
|
config.set(path+".open_inventory",item.getOpenInventory());
|
||||||
}
|
}
|
||||||
if(item.getCommands() != null && !item.getCommands().isEmpty()){
|
if(item.getClickActions() != null && !item.getClickActions().isEmpty()){
|
||||||
config.set(path+".click_commands",item.getCommands());
|
config.set(path+".click_actions",item.getClickActions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -128,21 +156,4 @@ public class InventoryConfigManager {
|
||||||
public FileConfiguration getConfig(){
|
public FileConfiguration getConfig(){
|
||||||
return configFile.getConfig();
|
return configFile.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkUpdate(){
|
|
||||||
Path pathConfig = Paths.get(configFile.getRoute());
|
|
||||||
try{
|
|
||||||
String text = new String(Files.readAllBytes(pathConfig));
|
|
||||||
/*
|
|
||||||
if(!text.contains("register_commands:")){
|
|
||||||
List<String> commands = new ArrayList<>();
|
|
||||||
getConfig().set("Config.register_commands", commands);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}catch(IOException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,16 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayersConfigManager {
|
public class PlayersConfigManager {
|
||||||
private ArrayList<CustomConfig> configFiles;
|
|
||||||
private String folderName;
|
private String folderName;
|
||||||
private PlayerKits2 plugin;
|
private PlayerKits2 plugin;
|
||||||
|
|
||||||
public PlayersConfigManager(PlayerKits2 plugin, String folderName){
|
public PlayersConfigManager(PlayerKits2 plugin, String folderName){
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.folderName = folderName;
|
this.folderName = folderName;
|
||||||
this.configFiles = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure() {
|
public void configure() {
|
||||||
createFolder();
|
createFolder();
|
||||||
reloadConfigs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reloadConfigs(){
|
|
||||||
this.configFiles = new ArrayList<>();
|
|
||||||
registerConfigFiles();
|
|
||||||
loadConfigs();
|
loadConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,65 +37,25 @@ public class PlayersConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveConfigFiles() {
|
|
||||||
for(int i=0;i<configFiles.size();i++) {
|
|
||||||
configFiles.get(i).saveConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerConfigFiles(){
|
|
||||||
String path = plugin.getDataFolder() + File.separator + folderName;
|
|
||||||
File folder = new File(path);
|
|
||||||
File[] listOfFiles = folder.listFiles();
|
|
||||||
for (int i=0;i<listOfFiles.length;i++) {
|
|
||||||
if(listOfFiles[i].isFile()) {
|
|
||||||
String pathName = listOfFiles[i].getName();
|
|
||||||
CustomConfig config = new CustomConfig(pathName, plugin, folderName, true);
|
|
||||||
config.registerConfig();
|
|
||||||
configFiles.add(config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<CustomConfig> getConfigs(){
|
|
||||||
return this.configFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean fileAlreadyRegistered(String pathName) {
|
|
||||||
for(int i=0;i<configFiles.size();i++) {
|
|
||||||
if(configFiles.get(i).getPath().equals(pathName)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomConfig getConfigFile(String pathName) {
|
public CustomConfig getConfigFile(String pathName) {
|
||||||
for(int i=0;i<configFiles.size();i++) {
|
|
||||||
if(configFiles.get(i).getPath().equals(pathName)) {
|
|
||||||
return configFiles.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean registerConfigFile(String pathName) {
|
|
||||||
if(!fileAlreadyRegistered(pathName)) {
|
|
||||||
CustomConfig config = new CustomConfig(pathName, plugin, folderName, true);
|
CustomConfig config = new CustomConfig(pathName, plugin, folderName, true);
|
||||||
config.registerConfig();
|
config.registerConfig();
|
||||||
configFiles.add(config);
|
return config;
|
||||||
return true;
|
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadConfigs(){
|
public void loadConfigs(){
|
||||||
Map<UUID, PlayerData> players = new HashMap<>();
|
Map<UUID, PlayerData> players = new HashMap<>();
|
||||||
|
|
||||||
for(CustomConfig configFile : configFiles) {
|
String path = plugin.getDataFolder() + File.separator + folderName;
|
||||||
FileConfiguration config = configFile.getConfig();
|
File folder = new File(path);
|
||||||
|
File[] listOfFiles = folder.listFiles();
|
||||||
|
for (File file : listOfFiles) {
|
||||||
|
if (file.isFile()) {
|
||||||
|
String pathName = file.getName();
|
||||||
|
CustomConfig configFile = new CustomConfig(pathName, plugin, folderName, true);
|
||||||
|
configFile.registerConfig();
|
||||||
|
|
||||||
|
FileConfiguration config = configFile.getConfig();
|
||||||
String uuidString = configFile.getPath().replace(".yml", "");
|
String uuidString = configFile.getPath().replace(".yml", "");
|
||||||
String name = config.getString("name");
|
String name = config.getString("name");
|
||||||
ArrayList<PlayerDataKit> playerDataKits = new ArrayList<>();
|
ArrayList<PlayerDataKit> playerDataKits = new ArrayList<>();
|
||||||
|
|
@ -129,6 +81,7 @@ public class PlayersConfigManager {
|
||||||
|
|
||||||
players.put(uuid, playerData);
|
players.put(uuid, playerData);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugin.getPlayerDataManager().setPlayers(players);
|
plugin.getPlayerDataManager().setPlayers(players);
|
||||||
}
|
}
|
||||||
|
|
@ -136,10 +89,6 @@ public class PlayersConfigManager {
|
||||||
public void saveConfig(PlayerData playerData){
|
public void saveConfig(PlayerData playerData){
|
||||||
String playerName = playerData.getName();
|
String playerName = playerData.getName();
|
||||||
CustomConfig playerConfig = getConfigFile(playerData.getUuid()+".yml");
|
CustomConfig playerConfig = getConfigFile(playerData.getUuid()+".yml");
|
||||||
if(playerConfig == null) {
|
|
||||||
registerConfigFile(playerData.getUuid()+".yml");
|
|
||||||
playerConfig = getConfigFile(playerData.getUuid()+".yml");
|
|
||||||
}
|
|
||||||
FileConfiguration config = playerConfig.getConfig();
|
FileConfiguration config = playerConfig.getConfig();
|
||||||
|
|
||||||
config.set("name", playerName);
|
config.set("name", playerName);
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,12 @@ import pk.ajneb97.model.inventory.InventoryPlayer;
|
||||||
import pk.ajneb97.model.inventory.ItemKitInventory;
|
import pk.ajneb97.model.inventory.ItemKitInventory;
|
||||||
import pk.ajneb97.model.inventory.KitInventory;
|
import pk.ajneb97.model.inventory.KitInventory;
|
||||||
import pk.ajneb97.model.item.KitItem;
|
import pk.ajneb97.model.item.KitItem;
|
||||||
|
import pk.ajneb97.utils.ActionUtils;
|
||||||
import pk.ajneb97.utils.ItemUtils;
|
import pk.ajneb97.utils.ItemUtils;
|
||||||
import pk.ajneb97.utils.PlayerUtils;
|
import pk.ajneb97.utils.PlayerUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InventoryManager {
|
public class InventoryManager {
|
||||||
|
|
@ -94,7 +96,6 @@ public class InventoryManager {
|
||||||
KitItemManager kitItemManager = plugin.getKitItemManager();
|
KitItemManager kitItemManager = plugin.getKitItemManager();
|
||||||
KitsManager kitsManager = plugin.getKitsManager();
|
KitsManager kitsManager = plugin.getKitsManager();
|
||||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||||
MessagesManager msgManager = plugin.getMessagesManager();
|
|
||||||
|
|
||||||
//Add items for all inventories
|
//Add items for all inventories
|
||||||
for(ItemKitInventory itemInventory : items){
|
for(ItemKitInventory itemInventory : items){
|
||||||
|
|
@ -102,7 +103,7 @@ public class InventoryManager {
|
||||||
String type = itemInventory.getType();
|
String type = itemInventory.getType();
|
||||||
if(type != null && type.startsWith("kit: ")){
|
if(type != null && type.startsWith("kit: ")){
|
||||||
setKit(type.replace("kit: ",""),inventoryPlayer.getPlayer(),inv,slot,kitsManager
|
setKit(type.replace("kit: ",""),inventoryPlayer.getPlayer(),inv,slot,kitsManager
|
||||||
,playerDataManager,kitItemManager,msgManager);
|
,playerDataManager,kitItemManager);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,18 +120,7 @@ public class InventoryManager {
|
||||||
if(openInventory != null) {
|
if(openInventory != null) {
|
||||||
item = ItemUtils.setTagStringItem(plugin,item, "playerkits_open_inventory", openInventory);
|
item = ItemUtils.setTagStringItem(plugin,item, "playerkits_open_inventory", openInventory);
|
||||||
}
|
}
|
||||||
List<String> commands = itemInventory.getCommands();
|
item = setItemActions(itemInventory,item);
|
||||||
if(commands != null && !commands.isEmpty()) {
|
|
||||||
String commandList = "";
|
|
||||||
for(int i=0;i<commands.size();i++) {
|
|
||||||
if(i==commands.size()-1) {
|
|
||||||
commandList=commandList+commands.get(i);
|
|
||||||
}else {
|
|
||||||
commandList=commandList+commands.get(i)+"|";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item = ItemUtils.setTagStringItem(plugin,item, "playerkits_item_commands", commandList);
|
|
||||||
}
|
|
||||||
|
|
||||||
inv.setItem(slot,item);
|
inv.setItem(slot,item);
|
||||||
}
|
}
|
||||||
|
|
@ -146,6 +136,22 @@ public class InventoryManager {
|
||||||
players.add(inventoryPlayer);
|
players.add(inventoryPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemStack setItemActions(ItemKitInventory itemInventory, ItemStack item) {
|
||||||
|
List<String> clickActions = itemInventory.getClickActions();
|
||||||
|
if(clickActions != null && !clickActions.isEmpty()) {
|
||||||
|
String actionsList = "";
|
||||||
|
for(int i=0;i<clickActions.size();i++) {
|
||||||
|
if(i==clickActions.size()-1) {
|
||||||
|
actionsList=actionsList+clickActions.get(i);
|
||||||
|
}else {
|
||||||
|
actionsList=actionsList+clickActions.get(i)+"|";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item = ItemUtils.setTagStringItem(plugin, item, "playerkits_item_actions", actionsList);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
public void setKitPreviewItems(Inventory inv,InventoryPlayer inventoryPlayer,KitInventory kitInventory){
|
public void setKitPreviewItems(Inventory inv,InventoryPlayer inventoryPlayer,KitInventory kitInventory){
|
||||||
KitItemManager kitItemManager = plugin.getKitItemManager();
|
KitItemManager kitItemManager = plugin.getKitItemManager();
|
||||||
KitsManager kitsManager = plugin.getKitsManager();
|
KitsManager kitsManager = plugin.getKitsManager();
|
||||||
|
|
@ -188,17 +194,17 @@ public class InventoryManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String itemActions = ItemUtils.getTagStringItem(plugin,item,"playerkits_item_actions");
|
||||||
|
if(itemActions != null){
|
||||||
|
clickOnActionItem(inventoryPlayer,itemActions);
|
||||||
|
}
|
||||||
|
|
||||||
String openInventory = ItemUtils.getTagStringItem(plugin,item,"playerkits_open_inventory");
|
String openInventory = ItemUtils.getTagStringItem(plugin,item,"playerkits_open_inventory");
|
||||||
if(openInventory != null){
|
if(openInventory != null){
|
||||||
clickOnOpenInventoryItem(inventoryPlayer,openInventory);
|
clickOnOpenInventoryItem(inventoryPlayer,openInventory);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String itemCommands = ItemUtils.getTagStringItem(plugin,item,"playerkits_item_commands");
|
|
||||||
if(itemCommands != null){
|
|
||||||
clickOnCommandItem(inventoryPlayer,itemCommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Requirements inventory
|
//Requirements inventory
|
||||||
if(inventoryPlayer.getInventoryName().equals("buy_requirements_inventory")){
|
if(inventoryPlayer.getInventoryName().equals("buy_requirements_inventory")){
|
||||||
String buyTag = ItemUtils.getTagStringItem(plugin,item,"playerkits_buy");
|
String buyTag = ItemUtils.getTagStringItem(plugin,item,"playerkits_buy");
|
||||||
|
|
@ -289,8 +295,18 @@ public class InventoryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clickOnActionItem(InventoryPlayer inventoryPlayer,String itemActions) {
|
||||||
|
String[] sep = itemActions.split("\\|");
|
||||||
|
|
||||||
|
KitsManager kitsManager = plugin.getKitsManager();
|
||||||
|
Player player = inventoryPlayer.getPlayer();
|
||||||
|
for(String action : sep){
|
||||||
|
kitsManager.executeAction(player,action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setKit(String kitName, Player player, Inventory inv, int slot, KitsManager kitsManager, PlayerDataManager playerDataManager
|
public void setKit(String kitName, Player player, Inventory inv, int slot, KitsManager kitsManager, PlayerDataManager playerDataManager
|
||||||
,KitItemManager kitItemManager,MessagesManager msgManager){
|
,KitItemManager kitItemManager){
|
||||||
Kit kit = kitsManager.getKitByName(kitName);
|
Kit kit = kitsManager.getKitByName(kitName);
|
||||||
if(kit == null){
|
if(kit == null){
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -377,12 +377,19 @@ public class KitsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeAction(Player player,String actionText){
|
public void executeAction(Player player,String actionText){
|
||||||
|
if(actionText.equals("close_inventory")){
|
||||||
|
ActionUtils.closeInventory(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int indexFirst = actionText.indexOf(" ");
|
int indexFirst = actionText.indexOf(" ");
|
||||||
String actionType = actionText.substring(0,indexFirst).replace(":","");
|
String actionType = actionText.substring(0,indexFirst).replace(":","");
|
||||||
String actionLine = actionText.substring(indexFirst+1);
|
String actionLine = actionText.substring(indexFirst+1);
|
||||||
actionLine = OtherUtils.replaceGlobalVariables(actionLine,player,plugin);
|
actionLine = OtherUtils.replaceGlobalVariables(actionLine,player,plugin);
|
||||||
|
|
||||||
switch(actionType){
|
switch(actionType){
|
||||||
|
case "message":
|
||||||
|
ActionUtils.message(player,actionLine);
|
||||||
|
break;
|
||||||
case "console_command":
|
case "console_command":
|
||||||
ActionUtils.consoleCommand(actionLine);
|
ActionUtils.consoleCommand(actionLine);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ public class MigrationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playersConfigManager.reloadConfigs();
|
playersConfigManager.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KitItem getDisplayItem(YamlConfiguration config,String path){
|
public KitItem getDisplayItem(YamlConfiguration config,String path){
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,8 @@ public class VerifyManager {
|
||||||
String actionName = actionText[0];
|
String actionName = actionText[0];
|
||||||
if(actionName.equals("console_command:") || actionName.equals("player_command:")
|
if(actionName.equals("console_command:") || actionName.equals("player_command:")
|
||||||
|| actionName.equals("playsound:") || actionName.equals("actionbar:")
|
|| actionName.equals("playsound:") || actionName.equals("actionbar:")
|
||||||
|| actionName.equals("title:") || actionName.equals("firework:")){
|
|| actionName.equals("title:") || actionName.equals("firework:")
|
||||||
|
|| actionName.equals("close_inventory") || actionName.equals("message:")){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
errors.add(new PKKitActionError(kitName+".yml",action.getAction(),false,kitName,actionGroup,(i+1)+""));
|
errors.add(new PKKitActionError(kitName+".yml",action.getAction(),false,kitName,actionGroup,(i+1)+""));
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ public class ItemKitInventory {
|
||||||
private String slotsString;
|
private String slotsString;
|
||||||
private KitItem item;
|
private KitItem item;
|
||||||
private String openInventory;
|
private String openInventory;
|
||||||
private List<String> commands;
|
private List<String> clickActions;
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
public ItemKitInventory(String slotsString, KitItem item, String openInventory, List<String> commands, String type) {
|
public ItemKitInventory(String slotsString, KitItem item, String openInventory, List<String> clickActions, String type) {
|
||||||
slots = new ArrayList<>();
|
slots = new ArrayList<>();
|
||||||
this.slotsString = slotsString;
|
this.slotsString = slotsString;
|
||||||
String[] slotsSep = slotsString.split(";");
|
String[] slotsSep = slotsString.split(";");
|
||||||
|
|
@ -32,7 +32,7 @@ public class ItemKitInventory {
|
||||||
|
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.openInventory = openInventory;
|
this.openInventory = openInventory;
|
||||||
this.commands = commands;
|
this.clickActions = clickActions;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,14 +60,6 @@ public class ItemKitInventory {
|
||||||
this.openInventory = openInventory;
|
this.openInventory = openInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCommands() {
|
|
||||||
return commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCommands(List<String> commands) {
|
|
||||||
this.commands = commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
@ -83,4 +75,12 @@ public class ItemKitInventory {
|
||||||
public void setSlotsString(String slotsString) {
|
public void setSlotsString(String slotsString) {
|
||||||
this.slotsString = slotsString;
|
this.slotsString = slotsString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getClickActions() {
|
||||||
|
return clickActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClickActions(List<String> clickActions) {
|
||||||
|
this.clickActions = clickActions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ public class InventoryUpdateTaskManager {
|
||||||
public void execute(){
|
public void execute(){
|
||||||
InventoryManager inventoryManager = plugin.getInventoryManager();
|
InventoryManager inventoryManager = plugin.getInventoryManager();
|
||||||
KitsManager kitsManager = plugin.getKitsManager();
|
KitsManager kitsManager = plugin.getKitsManager();
|
||||||
MessagesManager msgManager = plugin.getMessagesManager();
|
|
||||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||||
KitItemManager kitItemManager = plugin.getKitItemManager();
|
KitItemManager kitItemManager = plugin.getKitItemManager();
|
||||||
|
|
||||||
|
|
@ -51,7 +50,7 @@ public class InventoryUpdateTaskManager {
|
||||||
String kitName = ItemUtils.getTagStringItem(plugin,item,"playerkits_kit");
|
String kitName = ItemUtils.getTagStringItem(plugin,item,"playerkits_kit");
|
||||||
if(kitName != null){
|
if(kitName != null){
|
||||||
inventoryManager.setKit(kitName,player.getPlayer(),inv,i,kitsManager,
|
inventoryManager.setKit(kitName,player.getPlayer(),inv,i,kitsManager,
|
||||||
playerDataManager,kitItemManager,msgManager);
|
playerDataManager,kitItemManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class ActionUtils {
|
public class ActionUtils {
|
||||||
|
|
||||||
|
public static void message(Player player,String actionLine) {
|
||||||
|
player.sendMessage(MessagesManager.getColoredMessage(actionLine));
|
||||||
|
}
|
||||||
|
|
||||||
public static void consoleCommand(String actionLine){
|
public static void consoleCommand(String actionLine){
|
||||||
ConsoleCommandSender sender = Bukkit.getConsoleSender();
|
ConsoleCommandSender sender = Bukkit.getConsoleSender();
|
||||||
Bukkit.dispatchCommand(sender, actionLine);
|
Bukkit.dispatchCommand(sender, actionLine);
|
||||||
|
|
@ -129,4 +133,8 @@ public class ActionUtils {
|
||||||
firework.setFireworkMeta(fireworkMeta);
|
firework.setFireworkMeta(fireworkMeta);
|
||||||
firework.setMetadata("playerkits", new FixedMetadataValue(plugin, "no_damage"));
|
firework.setMetadata("playerkits", new FixedMetadataValue(plugin, "no_damage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void closeInventory(Player player) {
|
||||||
|
player.closeInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
main: pk.ajneb97.PlayerKits2
|
main: pk.ajneb97.PlayerKits2
|
||||||
version: 1.16.1
|
version: 1.17.1
|
||||||
name: PlayerKits2
|
name: PlayerKits2
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend: [Vault,PlaceholderAPI]
|
softdepend: [Vault,PlaceholderAPI]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue