diff --git a/.gitignore b/.gitignore index b384c6b9..28511343 100644 --- a/.gitignore +++ b/.gitignore @@ -115,3 +115,7 @@ run/ # gradle .gradle buildSrc/build +MiniGamesBox Classic/build +MiniGamesBox Database/build +MiniGamesBox Inventory/build +MiniGamesBox Utils/build diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/HandleItem.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/HandleItem.java new file mode 100644 index 00000000..1ecaebf0 --- /dev/null +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/HandleItem.java @@ -0,0 +1,8 @@ +package plugily.projects.minigamesbox.classic.kits; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public interface HandleItem { + ItemStack apply(Player player, ItemStack itemStack); +} diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitMenuHandler.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitMenuHandler.java index 9063ed2f..50085df8 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitMenuHandler.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitMenuHandler.java @@ -66,7 +66,7 @@ public void createMenu(Player player) { gui.addItem(new SimpleClickableItem(itemStack, event -> { event.setCancelled(true); - if(!(event.isLeftClick() || event.isRightClick()) || !(event.getWhoClicked() instanceof Player) || !ItemUtils.isItemStackNamed(event.getCurrentItem())) { + if(!(event.isLeftClick() || event.isRightClick()) || !(event.getWhoClicked() instanceof Player)) { return; } PluginArena arena = plugin.getArenaRegistry().getArena(player); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java index 5fbe8a9b..836671a1 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java @@ -18,13 +18,24 @@ package plugily.projects.minigamesbox.classic.kits; +import com.cryptomorin.xseries.XItemStack; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.inventory.ItemStack; import plugily.projects.minigamesbox.classic.PluginMain; +import plugily.projects.minigamesbox.classic.kits.basekits.FreeKit; import plugily.projects.minigamesbox.classic.kits.basekits.Kit; +import plugily.projects.minigamesbox.classic.kits.basekits.LevelKit; +import plugily.projects.minigamesbox.classic.kits.basekits.PremiumKit; import plugily.projects.minigamesbox.classic.kits.free.EmptyKit; import plugily.projects.minigamesbox.classic.utils.configuration.ConfigUtils; +import java.util.HashMap; import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.logging.Level; /** * @author Tigerpanzer_02 @@ -33,17 +44,19 @@ */ public class KitRegistry { - private final List kits = new java.util.ArrayList<>(); + public final List kits = new java.util.ArrayList<>(); private Kit defaultKit; - private final PluginMain plugin; + public final PluginMain plugin; + public FileConfiguration kitsConfig; + private static HandleItem handleItem; - //todo default kits - kit loading - possibility to edit kits with files - patreon will be ingame gui - kits.yml public KitRegistry(PluginMain plugin) { this.plugin = plugin; + kitsConfig = ConfigUtils.getConfig(plugin, "kits"); } /** - * Method for registering new kit + * Method for registering clone and empty kit * * @param kit Kit to register */ @@ -56,15 +69,164 @@ public void registerKit(Kit kit) { plugin.getDebugger().debug("Kit " + kit.getKey() + " can't be added as its already registered"); return; } - FileConfiguration config = ConfigUtils.getConfig(plugin, "kits"); - if(!config.getBoolean("Enabled-Game-Kits." + kit.getKey(), false)) { + + ConfigurationSection configurationSection = kit.getKitConfigSection(); + if(configurationSection != null && !configurationSection.getBoolean("enabled", false)) { plugin.getDebugger().debug("Kit " + kit.getKey() + " is disabled by kits.yml"); return; } + plugin.getDebugger().debug("Registered {0} kit", kit.getKey()); kits.add(kit); } + /** + * Registers the kits by loading their configurations. + */ + public void registerKits(List optionalConfigurations) { + + for (String key : kitsConfig.getKeys(false)) { + if (!Objects.equals(key, "Do-Not-Edit")) { + loadKitConfig(key, optionalConfigurations); + } + } + } + + /** + * Loads the configuration for a kit. + * + * @param kit_key the key of the kit to load the configuration for + */ + public void loadKitConfig(String kit_key, List optionalConfigurations) { + ConfigurationSection configurationSection = kitsConfig.getConfigurationSection(kit_key); + + if (configurationSection == null) { + plugin.getDebugger().debug(Level.SEVERE, "Kit " + kit_key + " does not have any configuration."); + plugin.getDebugger().debug(Level.SEVERE, "Kit" + kit_key + " will not be loaded."); + return; + } + + String kit_name = configurationSection.getString("name", kit_key); + + if (configurationSection.getConfigurationSection("display_item") == null) { + configurationSection.set("display_item", XItemStack.serialize(new ItemStack(Material.BEDROCK))); + } + + ItemStack itemStack = XItemStack.deserialize(Objects.requireNonNull(configurationSection.getConfigurationSection("display_item"))); + + if(!configurationSection.getBoolean("enabled", false)) { + plugin.getDebugger().debug("Kit " + kit_key + " is disabled by kits.yml"); + return; + } + + String kitType = configurationSection.getString("kit_type"); + + if (kitType == null) { + plugin.getDebugger().debug(Level.SEVERE, "Kit " + kit_key + " kit_type is null."); + plugin.getDebugger().debug(Level.SEVERE, "Kit" + kit_key + " will not be loaded."); + return; + } + + Kit kit; + + switch (kitType) { + case "free": { + kit = new FreeKit(kit_key, kit_name, itemStack); + break; + } + case "level": { + kit = new LevelKit(kit_key, kit_name, itemStack); + ((LevelKit) kit).setLevel(configurationSection.getInt("required-level")); + break; + } + case "premium": { + kit = new PremiumKit(kit_key, kit_name, itemStack); + break; + } + default: { + plugin.getDebugger().debug(Level.SEVERE, "Kit " + kit_key + " kit_type is not recognised."); + plugin.getDebugger().debug(Level.SEVERE, "Kit" + kit_key + " will not be loaded."); + return; + } + } + + if (configurationSection.getString("unlockedOnDefault") == null) { + plugin.getDebugger().debug(Level.SEVERE, "Kit " + kit_key + " does not have an unlockedOnDefault configuration."); + plugin.getDebugger().debug(Level.SEVERE, "Kit" + kit_key + " will not be loaded."); + return; + } + kit.setUnlockedOnDefault(configurationSection.getBoolean("unlockedOnDefault")); + + HashMap kitItems = new HashMap<>(); + + ConfigurationSection inventoryConfigurationSection = configurationSection.getConfigurationSection("inventory"); + if (inventoryConfigurationSection != null) { + inventoryConfigurationSection.getKeys(false).forEach((k) -> { + + ConfigurationSection itemConfigurationSection = inventoryConfigurationSection.getConfigurationSection(k); + assert itemConfigurationSection != null; + + ConfigurationSection itemStackConfigurationSection = itemConfigurationSection.getConfigurationSection("item"); + assert itemStackConfigurationSection != null; + ItemStack item = XItemStack.deserialize(itemStackConfigurationSection); + Integer slot = itemConfigurationSection.getInt("slot"); + + kitItems.put(item, slot); + }); + kit.setKitItems(kitItems); + } + else { + plugin.getDebugger().debug(Level.SEVERE, "The kit " + kit.getKey() + " does not have an inventory configuration section."); + plugin.getDebugger().debug(Level.SEVERE, "The kit " + kit.getKey() + " will not give any inventory items."); + } + + + ConfigurationSection armourConfigurationSection = configurationSection.getConfigurationSection("armour"); + if (armourConfigurationSection != null) { + + ConfigurationSection helmetConfigurationSection = armourConfigurationSection.getConfigurationSection("helmet"); + if (helmetConfigurationSection != null) { + kit.setKitHelmet(XItemStack.deserialize(helmetConfigurationSection)); + } + + ConfigurationSection chestplateConfigurationSection = armourConfigurationSection.getConfigurationSection("chestplate"); + if (chestplateConfigurationSection != null) { + kit.setKitChestplate(XItemStack.deserialize(chestplateConfigurationSection)); + } + + ConfigurationSection leggingsConfigurationSection = armourConfigurationSection.getConfigurationSection("leggings"); + if (leggingsConfigurationSection != null) { + kit.setKitLeggings(XItemStack.deserialize(leggingsConfigurationSection)); + } + + ConfigurationSection bootsConfigurationSection = armourConfigurationSection.getConfigurationSection("boots"); + if (bootsConfigurationSection != null) { + kit.setKitBoots(XItemStack.deserialize(bootsConfigurationSection)); + } + } + else { + plugin.getDebugger().debug(Level.SEVERE, "The kit " + kit.getKey() + " does not have an armour configuration section."); + plugin.getDebugger().debug(Level.SEVERE, "The kit " + kit.getKey() + " will not give any armour items."); + } + + if (configurationSection.getString("default_kit") != null) { + this.setDefaultKit(kit); + plugin.getDebugger().debug("Default kit set to " + kit.getKey()); + } + + if (optionalConfigurations != null) { + optionalConfigurations.forEach((k) -> { + if (configurationSection.contains(k)) { + kit.addOptionalConfiguration(k, configurationSection.get(k)); + plugin.getDebugger().debug("Kit " + kit.getKey() + " has optional configuration " + k); + } + }); + } + + plugin.getDebugger().debug("Kit " + kit.getKey() + " loaded."); + kits.add(kit); + } + /** * Return default game kit * @@ -72,7 +234,7 @@ public void registerKit(Kit kit) { */ public Kit getDefaultKit() { if(defaultKit == null) { - setDefaultKit(new EmptyKit()); + setDefaultKit(new EmptyKit("default", "default")); } plugin.getDebugger().debug("getDefaultKit is {0}", defaultKit.getName()); return defaultKit; @@ -97,4 +259,12 @@ public List getKits() { return kits; } + public static HandleItem getHandleItem() { + return handleItem; + } + + public static void setHandleItem(HandleItem handleItem) { + KitRegistry.handleItem = handleItem; + } + } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/FreeKit.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/FreeKit.java index 1d87a8f6..b4630553 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/FreeKit.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/FreeKit.java @@ -18,24 +18,26 @@ package plugily.projects.minigamesbox.classic.kits.basekits; -import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder; +import plugily.projects.minigamesbox.classic.kits.KitRegistry; /** * @author Tigerpanzer_02 *

* Created at 21.09.2021 */ -public abstract class FreeKit extends Kit { +public class FreeKit extends Kit { - public abstract Material getMaterial(); + public FreeKit(String key, String name, ItemStack itemStack) { + super(key, name, itemStack); + } + /** + * @return true + */ @Override - public ItemStack getItemStack() { - return new ItemBuilder(getMaterial()) - .name(getName()) - .lore(getDescription()) - .build(); + public boolean isUnlockedByPlayer(Player p) { + return true; } } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java index 66a4540f..3e9853c6 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java @@ -18,14 +18,16 @@ package plugily.projects.minigamesbox.classic.kits.basekits; -import org.bukkit.ChatColor; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import plugily.projects.minigamesbox.classic.PluginMain; +import plugily.projects.minigamesbox.classic.kits.KitRegistry; import plugily.projects.minigamesbox.classic.utils.configuration.ConfigUtils; +import java.util.HashMap; import java.util.List; /** @@ -33,97 +35,219 @@ *

* Created at 21.09.2021 */ -public abstract class Kit { +public class Kit { - private static final PluginMain plugin = JavaPlugin.getPlugin(PluginMain.class); + private static final PluginMain plugin = JavaPlugin.getPlugin(PluginMain.class); - private final FileConfiguration kitsConfig = ConfigUtils.getConfig(plugin, "kits"); + private FileConfiguration kitsConfig = ConfigUtils.getConfig(plugin, "kits"); - private String name = ""; + private String name; - private String key = ""; - private boolean unlockedOnDefault = false; - private String[] description = new String[0]; + private final String key; - protected Kit() { - } + private final ItemStack itemStack; - public Kit(String name) { - setName(name); - setKey(name); - } + private String kitPermission = ""; - public Kit(String name, String key) { - setName(name); - setKey(key); - } + private boolean unlockedOnDefault = false; + private String[] description = new String[0]; - public abstract boolean isUnlockedByPlayer(Player p); + private final HashMap optionalConfiguration = new HashMap<>(); - public boolean isUnlockedOnDefault() { - return unlockedOnDefault; - } + private HashMap kitItems = new HashMap<>(); + private ItemStack kitHelmet; + private ItemStack kitChestplate; + private ItemStack kitLeggings; + private ItemStack kitBoots; - public void setUnlockedOnDefault(boolean unlockedOnDefault) { - this.unlockedOnDefault = unlockedOnDefault; - } + public Kit(String key, String name, ItemStack itemStack) { + this.key = key; + this.name = name; + this.itemStack = itemStack; + } + + public boolean isUnlockedByPlayer(Player p) { + return false; + } + + public boolean isUnlockedOnDefault() { + return unlockedOnDefault; + } + + public void setUnlockedOnDefault(boolean unlockedOnDefault) { + this.unlockedOnDefault = unlockedOnDefault; + } + + public void addKitItem(ItemStack item, Integer slot) { + kitItems.put(item, slot); + } + + public HashMap getKitItems() { + return kitItems; + } + + public void setKitItems(HashMap kitItems) { + this.kitItems = kitItems; + } + + /** + * @return main plugin + */ + public PluginMain getPlugin() { + return plugin; + } + + /** + * @return config file of kits + */ + public FileConfiguration getKitsConfig() { + return kitsConfig; + } + + public void saveKitsConfig() { + ConfigUtils.saveConfig(plugin, kitsConfig, "kits"); + kitsConfig = ConfigUtils.getConfig(plugin, "kits"); + } + + /** + * Retrieves the name of the object. + * + * @return the name of the object + */ + public String getName() { + return name; + } + + /** + * Sets the name of the object. + * + * @param name the new name to set + */ + public void setName(String name) { + if (name != null) { + this.name = name; + } + } + + public String getKey() { + if (key.isEmpty()) { + return name; + } + return key; + } - /** - * @return main plugin - */ - public PluginMain getPlugin() { - return plugin; - } + public ItemStack getItemStack() { + ItemStack itemStack1 = itemStack; + itemStack1.setAmount(1); + return itemStack1; + } - /** - * @return config file of kits - */ - public FileConfiguration getKitsConfig() { - return kitsConfig; - } + public String[] getDescription() { + return description.clone(); + } - public String getName() { - return name; - } + public void setDescription(String[] description) { + if (description != null) { + this.description = description.clone(); + } + } - public void setName(String name) { - if(name != null) { - this.name = name; + public void setDescription(List description) { + if (description != null) { + this.description = description.toArray(new String[0]); + } } - } - public void setKey(String key) { - this.key = key; - } + public void giveKitItems(Player player) { + player.getInventory().clear(); + player.getInventory().setArmorContents(null); + kitItems.forEach((item, slot) -> player.getInventory().setItem(slot, handleItem(player, item))); + if (kitHelmet != null) player.getInventory().setHelmet(handleItem(player, kitHelmet)); + if (kitChestplate != null) player.getInventory().setChestplate(handleItem(player, kitChestplate)); + if (kitLeggings != null) player.getInventory().setLeggings(handleItem(player, kitLeggings)); + if (kitBoots != null) player.getInventory().setBoots(handleItem(player, kitBoots)); + } - public String getKey() { - if (key.equalsIgnoreCase("")) { - return name; + /** + * This method allows you to change kit items given to a player from their original form. + * If nothing is to be changed for any items, then return itemstack straight away. + * + * @param player Player to give the item to + * @param itemStack The item stack to be handled + * @return The item stack after being handled + */ + public ItemStack handleItem(Player player, ItemStack itemStack) { + return KitRegistry.getHandleItem().apply(player, itemStack); } - return key; - } - public String[] getDescription() { - return description.clone(); - } + /** + * @return Returns the configuration path for the kit + */ + public String getKitConfigPath() { + return key; + } - public void setDescription(String[] description) { - if(description != null) { - this.description = description.clone(); + /** + * @return Returns the configuration section for the kit + */ + public ConfigurationSection getKitConfigSection() { + ConfigurationSection configurationSection = kitsConfig.getConfigurationSection(getKitConfigPath()); + if (configurationSection == null) { + kitsConfig.createSection(getKitConfigPath()); + } + return configurationSection; } - } - public void setDescription(List description) { - if(description != null) { - this.description = description.toArray(new String[0]); + public ItemStack getKitHelmet() { + return kitHelmet; } - } - public abstract ItemStack getItemStack(); + public void setKitHelmet(ItemStack kitHelmet) { + this.kitHelmet = kitHelmet; + } - public abstract void giveKitItems(Player player); + public ItemStack getKitChestplate() { + return kitChestplate; + } - public abstract void reStock(Player player); + public void setKitChestplate(ItemStack kitChestplate) { + this.kitChestplate = kitChestplate; + } + + public ItemStack getKitLeggings() { + return kitLeggings; + } -} + public void setKitLeggings(ItemStack kitLeggings) { + this.kitLeggings = kitLeggings; + } + + public ItemStack getKitBoots() { + return kitBoots; + } + + public void setKitBoots(ItemStack kitBoots) { + this.kitBoots = kitBoots; + } + + public void setKitPermission(String kitPermission) { + this.kitPermission = kitPermission; + } + + public String getKitPermission() { + return kitPermission; + } + + public Object getOptionalConfiguration(String path, Object defaultValue) { + return optionalConfiguration.getOrDefault(path, defaultValue); + } + + public Object getOptionalConfiguration(String path) { + return optionalConfiguration.get(path); + } + + public void addOptionalConfiguration(String path, Object object) { + optionalConfiguration.put(path, object); + } +} \ No newline at end of file diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/LevelKit.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/LevelKit.java index 4c8bdda9..a7e32666 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/LevelKit.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/LevelKit.java @@ -18,20 +18,22 @@ package plugily.projects.minigamesbox.classic.kits.basekits; -import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder; -import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder; /** * @author Tigerpanzer_02 *

* Created at 21.09.2021 */ -public abstract class LevelKit extends Kit { +public class LevelKit extends Kit { private int level; + public LevelKit(String key, String name, ItemStack itemStack) { + super(key, name, itemStack); + } + public int getLevel() { return level; } @@ -40,14 +42,8 @@ public void setLevel(int level) { this.level = level; } - public abstract Material getMaterial(); - @Override - public ItemStack getItemStack() { - return new ItemBuilder(getMaterial()) - .name(getName()) - .lore(getDescription()) - .lore(new MessageBuilder("KIT_KIT_MENU_LORE_UNLOCK_LEVEL").asKey().integer(level).build()) - .build(); + public boolean isUnlockedByPlayer(Player p) { + return getPlugin().getUserManager().getUser(p).getStatistic("LEVEL") >= this.getLevel() || p.hasPermission(this.getKitPermission()); } } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/PremiumKit.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/PremiumKit.java index 4456bc08..fb3baad5 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/PremiumKit.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/PremiumKit.java @@ -18,28 +18,18 @@ package plugily.projects.minigamesbox.classic.kits.basekits; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder; -import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder; /** * @author Tigerpanzer_02 *

* Created at 21.09.2021 */ -public abstract class PremiumKit extends Kit { +public class PremiumKit extends Kit { - public abstract Material getMaterial(); - - @Override - public ItemStack getItemStack() { - return new ItemBuilder(getMaterial()) - .name(getName()) - .lore(getDescription()) - .lore(new MessageBuilder("KIT_KIT_MENU_LORE_UNLOCK_STORE").asKey().build()) - .build(); + public PremiumKit(String key, String name, ItemStack itemStack) { + super(key, name, itemStack); } @Override diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/CloneKit.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/CloneKit.java index 9e697a26..560d715f 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/CloneKit.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/CloneKit.java @@ -19,13 +19,8 @@ package plugily.projects.minigamesbox.classic.kits.free; import com.cryptomorin.xseries.XMaterial; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder; import plugily.projects.minigamesbox.classic.kits.basekits.FreeKit; -import plugily.projects.minigamesbox.classic.utils.helper.ArmorHelper; -import plugily.projects.minigamesbox.classic.utils.helper.WeaponHelper; import java.util.List; @@ -36,34 +31,11 @@ */ public class CloneKit extends FreeKit { - public CloneKit() { + public CloneKit(String name) { + super("Clone", name, XMaterial.WOODEN_SWORD.parseItem()); setName(new MessageBuilder("KITS_EXAMPLE_NAME").asKey().build()); - setKey("Clone"); List description = getPlugin().getBukkitHelper().splitString(new MessageBuilder("KITS_EXAMPLE_DESCRIPTION").asKey().build(), 40); setDescription(description.toArray(new String[0])); getPlugin().getKitRegistry().registerKit(this); } - - @Override - public boolean isUnlockedByPlayer(Player player) { - return true; - } - - @Override - public void giveKitItems(Player player) { - player.getInventory().addItem(WeaponHelper.getUnBreakingSword(WeaponHelper.ResourceType.WOOD, 10)); - ArmorHelper.setArmor(player, ArmorHelper.ArmorType.LEATHER); - player.getInventory().addItem(new ItemStack(XMaterial.COOKED_PORKCHOP.parseMaterial(), 8)); - - } - - @Override - public Material getMaterial() { - return XMaterial.WOODEN_SWORD.parseMaterial(); - } - - @Override - public void reStock(Player player) { - //no restock items for this kit - } } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/EmptyKit.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/EmptyKit.java index 735f5953..c5b137bb 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/EmptyKit.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/free/EmptyKit.java @@ -19,8 +19,6 @@ package plugily.projects.minigamesbox.classic.kits.free; import com.cryptomorin.xseries.XMaterial; -import org.bukkit.Material; -import org.bukkit.entity.Player; import plugily.projects.minigamesbox.classic.kits.basekits.FreeKit; import java.util.List; @@ -31,31 +29,10 @@ * Created at 02.12.2021 */ public class EmptyKit extends FreeKit { - - public EmptyKit() { - setName(""); - setKey(""); + public EmptyKit(String key, String name) { + super(key, name, XMaterial.BEDROCK.parseItem()); List description = getPlugin().getBukkitHelper().splitString("", 40); setDescription(description.toArray(new String[0])); getPlugin().getKitRegistry().registerKit(this); } - - @Override - public boolean isUnlockedByPlayer(Player player) { - return true; - } - - @Override - public void giveKitItems(Player player) { - } - - @Override - public Material getMaterial() { - return XMaterial.BEDROCK.parseMaterial(); - } - - @Override - public void reStock(Player player) { - //no restock items for this kit - } } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/configuration/ConfigUtils.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/configuration/ConfigUtils.java index 91358867..51ec8d96 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/configuration/ConfigUtils.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/configuration/ConfigUtils.java @@ -92,5 +92,4 @@ public static void saveConfig(JavaPlugin plugin, FileConfiguration config, Strin Bukkit.getConsoleSender().sendMessage("Create blank file " + name + ".yml or restart the server!"); } } - } diff --git a/MiniGamesBox Classic/src/main/resources/kits.yml b/MiniGamesBox Classic/src/main/resources/kits.yml index 2c45df3f..212f63fb 100644 --- a/MiniGamesBox Classic/src/main/resources/kits.yml +++ b/MiniGamesBox Classic/src/main/resources/kits.yml @@ -78,14 +78,4 @@ Kit-Settings: # You edited it, huh? Next time hurt yourself! Do-Not-Edit: File-Version: 1 - Core-Version: 2 - - - - - - - - - - + Core-Version: 2 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 467fb322..5b515010 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ # along with this program. If not, see . # group=plugily.projects -version=1.3.2-SNAPSHOT6 \ No newline at end of file +version=1.3.2-SNAPSHOT14