Added the ability to change the currency symbol.

Corrected the sound default config value.
Added a chance option for all kit items.
Kit storage system redone.
Kit animations added.
Cleaned up code.
Fixed issues with "Any" kit keys
This commit is contained in:
Brianna O'Keefe 2018-10-24 17:56:23 -04:00
parent cf35947043
commit 49d2c70ece
35 changed files with 705 additions and 202 deletions

View File

@ -133,7 +133,9 @@ public enum Lang {
LAST("Last", "&7Last Page"), LAST("Last", "&7Last Page"),
ECO_SENT("Eco_Sent", "&7You received &a{AMT}&7."), ECO_SENT("Eco_Sent", "&7You received &a{AMT}&7."),
INVENTORY_FULL("Inventory-full", "&cYour inventory is too full to claim this kit!"); INVENTORY_FULL("Inventory-full", "&cYour inventory is too full to claim this kit!"),
CRATE_WON("Crate-won", "&7You got a &6{ITEM}&7.");
private static FileConfiguration LANG; private static FileConfiguration LANG;
@ -166,6 +168,7 @@ public enum Lang {
value = value.replace("{AMT}", ob.toString()); value = value.replace("{AMT}", ob.toString());
value = value.replace("{COST}", ob.toString()); value = value.replace("{COST}", ob.toString());
value = value.replace("{PRICE}", ob.toString()); value = value.replace("{PRICE}", ob.toString());
value = value.replace("{ITEM}", ob.toString());
value = value.replace("{TIME}", ob.toString()); value = value.replace("{TIME}", ob.toString());
} }
return value; return value;

View File

@ -10,12 +10,9 @@ import com.songoda.ultimatekits.handlers.HologramHandler;
import com.songoda.ultimatekits.handlers.ParticleHandler; import com.songoda.ultimatekits.handlers.ParticleHandler;
import com.songoda.ultimatekits.key.Key; import com.songoda.ultimatekits.key.Key;
import com.songoda.ultimatekits.key.KeyManager; import com.songoda.ultimatekits.key.KeyManager;
import com.songoda.ultimatekits.kit.BlockEditor; import com.songoda.ultimatekits.editor.BlockEditor;
import com.songoda.ultimatekits.kit.KitEditor; import com.songoda.ultimatekits.editor.KitEditor;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.*;
import com.songoda.ultimatekits.kit.object.KitBlockData;
import com.songoda.ultimatekits.kit.object.KitManager;
import com.songoda.ultimatekits.kit.object.KitType;
import com.songoda.ultimatekits.player.PlayerData; import com.songoda.ultimatekits.player.PlayerData;
import com.songoda.ultimatekits.player.PlayerDataManager; import com.songoda.ultimatekits.player.PlayerDataManager;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
@ -160,9 +157,16 @@ public class UltimateKits extends JavaPlugin {
Material material = kitFile.getConfig().contains("Kits." + kitName + ".displayItem") ? Material.valueOf(kitFile.getConfig().getString("Kits." + kitName + ".displayItem")) : null; Material material = kitFile.getConfig().contains("Kits." + kitName + ".displayItem") ? Material.valueOf(kitFile.getConfig().getString("Kits." + kitName + ".displayItem")) : null;
boolean hidden = kitFile.getConfig().getBoolean("Kits." + kitName + ".hidden"); boolean hidden = kitFile.getConfig().getBoolean("Kits." + kitName + ".hidden");
double price = kitFile.getConfig().getDouble("Kits." + kitName + ".price"); double price = kitFile.getConfig().getDouble("Kits." + kitName + ".price");
List<String> contents = kitFile.getConfig().getStringList("Kits." + kitName + ".items"); List<String> strContents = kitFile.getConfig().getStringList("Kits." + kitName + ".items");
String kitAnimation = kitFile.getConfig().getString("Kits." + kitName + ".animation", KitAnimation.NONE.name());
Kit kit = new Kit(kitName, title, link, price, material, delay, hidden, contents); List<KitItem> contents = new ArrayList<>();
for (String string : strContents) {
contents.add(new KitItem(string));
}
Kit kit = new Kit(kitName, title, link, price, material, delay, hidden, contents, KitAnimation.valueOf(kitAnimation));
kitManager.addKit(kit); kitManager.addKit(kit);
} catch (Exception ex) { } catch (Exception ex) {
console.sendMessage(Arconix.pl().getApi().format().formatText("&cYour kit &4" + kitName + " &cis setup incorrectly.")); console.sendMessage(Arconix.pl().getApi().format().formatText("&cYour kit &4" + kitName + " &cis setup incorrectly."));
@ -225,9 +229,16 @@ public class UltimateKits extends JavaPlugin {
kitFile.getConfig().set("Kits." + kit.getName() + ".link", kit.getLink()); kitFile.getConfig().set("Kits." + kit.getName() + ".link", kit.getLink());
kitFile.getConfig().set("Kits." + kit.getName() + ".price", kit.getPrice()); kitFile.getConfig().set("Kits." + kit.getName() + ".price", kit.getPrice());
kitFile.getConfig().set("Kits." + kit.getName() + ".hidden", kit.isHidden()); kitFile.getConfig().set("Kits." + kit.getName() + ".hidden", kit.isHidden());
kitFile.getConfig().set("Kits." + kit.getName() + ".animation", kit.getKitAnimation().name());
if (kit.getDisplayItem() != null) if (kit.getDisplayItem() != null)
kitFile.getConfig().set("Kits." + kit.getName() + ".displayItem", kit.getDisplayItem().toString()); kitFile.getConfig().set("Kits." + kit.getName() + ".displayItem", kit.getDisplayItem().toString());
kitFile.getConfig().set("Kits." + kit.getName() + ".items", kit.getContents());
List<KitItem> contents = kit.getContents();
List<String> strContents = new ArrayList<>();
for (KitItem item : contents) strContents.add(item.getSerialized());
kitFile.getConfig().set("Kits." + kit.getName() + ".items", strContents);
} }
// Wipe old block information. // Wipe old block information.

View File

@ -4,8 +4,7 @@ import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand; import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,7 +27,7 @@ public class CommandCreatekit extends AbstractCommand {
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText("&aThat kit doesn't exist. Creating it now.")); p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText("&aThat kit doesn't exist. Creating it now."));
Kit kit = new Kit(kitStr.trim()); Kit kit = new Kit(kitStr.trim());
UltimateKits.getInstance().getKitManager().addKit(kit); UltimateKits.getInstance().getKitManager().addKit(kit);
instance.getKitEditor().openOverview(kit, p, false, null); instance.getKitEditor().openOverview(kit, p, false, null, 0);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -36,7 +36,7 @@ public class CommandEdit extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
instance.getKitEditor().openOverview(instance.getKitManager().getKit(kitStr), player, false, null); instance.getKitEditor().openOverview(instance.getKitManager().getKit(kitStr), player, false, null, 0);
} }
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -5,7 +5,7 @@ import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand; import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.key.Key; import com.songoda.ultimatekits.key.Key;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -53,12 +53,12 @@ public class CommandKey extends AbstractCommand {
if (!args[3].trim().equals("all")) { if (!args[3].trim().equals("all")) {
Player p = Bukkit.getPlayer(args[3]); Player p = Bukkit.getPlayer(args[3]);
p.getInventory().addItem(key.getKeyItem(kit, amt)); p.getInventory().addItem(key.getKeyItem(kit, amt));
p.sendMessage(instance.references.getPrefix() + Lang.KEY_GIVEN.getConfigValue(kit.getShowableName())); p.sendMessage(instance.references.getPrefix() + Lang.KEY_GIVEN.getConfigValue((kit == null ? "Any" : kit.getShowableName())));
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }
for (Player pl : instance.getServer().getOnlinePlayers()) { for (Player pl : instance.getServer().getOnlinePlayers()) {
pl.getInventory().addItem(key.getKeyItem(kit, amt)); pl.getInventory().addItem(key.getKeyItem(kit, amt));
pl.sendMessage(instance.references.getPrefix() + Lang.KEY_GIVEN.getConfigValue(kit.getShowableName())); pl.sendMessage(instance.references.getPrefix() + Lang.KEY_GIVEN.getConfigValue((kit == null ? "Any" : kit.getShowableName())));
} }
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -5,7 +5,7 @@ import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand; import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.kit.KitsGUI; import com.songoda.ultimatekits.kit.KitsGUI;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Methods; import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
public class CommandKits extends AbstractCommand { public class CommandKits extends AbstractCommand {
public CommandKits() { public CommandKits() {
super("Kits", null, false, false); super("Kits", null, true, false);
} }
@Override @Override

View File

@ -3,7 +3,7 @@ package com.songoda.ultimatekits.command.commands;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand; import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -4,7 +4,7 @@ import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand; import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,12 +1,11 @@
package com.songoda.ultimatekits.kit; package com.songoda.ultimatekits.editor;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.BlockEditorPlayerData; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.kit.object.KitBlockData; import com.songoda.ultimatekits.kit.KitType;
import com.songoda.ultimatekits.kit.object.KitType;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods; import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -1,5 +1,7 @@
package com.songoda.ultimatekits.kit.object; package com.songoda.ultimatekits.editor;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,10 +1,12 @@
package com.songoda.ultimatekits.kit; package com.songoda.ultimatekits.editor;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitEditorPlayerData; import com.songoda.ultimatekits.kit.KitAnimation;
import com.songoda.ultimatekits.kit.KitItem;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods; import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -30,7 +32,7 @@ public class KitEditor {
this.instance = instance; this.instance = instance;
} }
public void openOverview(Kit kit, Player player, boolean backb, ItemStack command) { public void openOverview(Kit kit, Player player, boolean backb, ItemStack command, int slot) {
try { try {
KitEditorPlayerData playerData = getDataFor(player); KitEditorPlayerData playerData = getDataFor(player);
@ -47,7 +49,7 @@ public class KitEditor {
exit.setItemMeta(exitmeta); exit.setItemMeta(exitmeta);
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3); ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack back = head2; ItemStack back;
back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"); back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta(); SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
back.setDurability((short) 3); back.setDurability((short) 3);
@ -60,7 +62,7 @@ public class KitEditor {
itmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&5&l" + playerData.getKit().getName())); itmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&5&l" + playerData.getKit().getName()));
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&fPermissions:")); lore.add(Arconix.pl().getApi().format().formatText("&fPermissions:"));
lore.add(Arconix.pl().getApi().format().formatText("&7essentials.kit." + playerData.getKit().getName().toLowerCase())); lore.add(Arconix.pl().getApi().format().formatText("&7ultimatekits.kit." + playerData.getKit().getName().toLowerCase()));
itmeta.setLore(lore); itmeta.setLore(lore);
it.setItemMeta(itmeta); it.setItemMeta(itmeta);
@ -75,9 +77,16 @@ public class KitEditor {
i.setItem(8, exit); i.setItem(8, exit);
int num = 10; int num = 10;
List<ItemStack> list = kit.getReadableContents(player, true); List<ItemStack> list = kit.getReadableContents(player, true, true);
for (ItemStack is : list) { for (ItemStack iss : list) {
/* if (num == 17 || num == 36)
num++;
KitItem item = new KitItem(iss);
if (slot != 0 && slot == num) item.setChance(item.getChance() == 100 ? 5 : (item.getChance() + 5));
ItemStack is = item.getMoveableItem();
ItemMeta meta; ItemMeta meta;
if (is.hasItemMeta()) meta = is.getItemMeta(); if (is.hasItemMeta()) meta = is.getItemMeta();
@ -87,19 +96,20 @@ public class KitEditor {
if (meta.hasLore()) itemLore = meta.getLore(); if (meta.hasLore()) itemLore = meta.getLore();
else itemLore = new ArrayList<>(); else itemLore = new ArrayList<>();
itemLore.add(TextComponent.convertToInvisibleString("----"));
itemLore.add(TextComponent.formatText("&7Chance: &6" + item.getChance() + "%"));
itemLore.add(""); itemLore.add("");
itemLore.add(TextComponent.formatText("&7Left-Click: &6To set a display item.")); if (playerData.isInFuction()) {
itemLore.add(TextComponent.formatText("&7Middle-Click: &6To set a display name.")); itemLore.add(TextComponent.formatText("&7Left-Click: &6To set a display item."));
itemLore.add(TextComponent.formatText("&7Right-Click: &6To set display lore.")); itemLore.add(TextComponent.formatText("&7Middle-Click: &6To set a display name."));
itemLore.add(TextComponent.formatText("&7Shift-Click: &6To set crate percentage.")); itemLore.add(TextComponent.formatText("&7Right-Click: &6To set display lore."));
itemLore.add(""); itemLore.add(TextComponent.formatText("&7Shift-Click: &6To set chance."));
itemLore.add(TextComponent.formatText("&6Leave function mode to move items.")); itemLore.add("");
itemLore.add(TextComponent.formatText("&6Leave function mode to move items."));
}
meta.setLore(itemLore); meta.setLore(itemLore);
is.setItemMeta(meta); is.setItemMeta(meta);
*/
if (num == 17 || num == 36)
num++;
if (is.getAmount() > 64) { if (is.getAmount() > 64) {
int overflow = is.getAmount() % 64; int overflow = is.getAmount() % 64;
int stackamt = (int) ((long) (is.getAmount() / 64)); int stackamt = (int) ((long) (is.getAmount() / 64));
@ -162,23 +172,41 @@ public class KitEditor {
} }
public void updateInvButton(Inventory i, KitEditorPlayerData playerData) { public void updateInvButton(Inventory i, KitEditorPlayerData playerData) {
ItemStack alli = new ItemStack(Material.ITEM_FRAME, 1); ItemStack alli = new ItemStack(Material.PAPER, 1);
ItemMeta allmeta = alli.getItemMeta(); ItemMeta allmeta = alli.getItemMeta();
if (!playerData.isInFuction()) {
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Switch To Item Editing"));
List<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&7Click to enable"));
lore.add(Arconix.pl().getApi().format().formatText("&7item editing."));
allmeta.setLore(lore);
} else {
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Switch To Item Moving"));
List<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&7Click to switch back"));
lore.add(Arconix.pl().getApi().format().formatText("&7to item moving."));
allmeta.setLore(lore);
}
alli.setItemMeta(allmeta);
i.setItem(48, alli);
alli = new ItemStack(Material.ITEM_FRAME, 1);
allmeta = alli.getItemMeta();
if (!playerData.isInInventory()) { if (!playerData.isInInventory()) {
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Switch To Your Inventory")); allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Switch To Your Inventory"));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&7Clicking to switch to")); lore.add(Arconix.pl().getApi().format().formatText("&7Click to switch to"));
lore.add(Arconix.pl().getApi().format().formatText("&7your inventory.")); lore.add(Arconix.pl().getApi().format().formatText("&7your inventory."));
allmeta.setLore(lore); allmeta.setLore(lore);
} else { } else {
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Switch To Kit Functions")); allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Switch To Kit Functions"));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&7Clicking to switch back")); lore.add(Arconix.pl().getApi().format().formatText("&7Click to switch back"));
lore.add(Arconix.pl().getApi().format().formatText("&7to the kit functions.")); lore.add(Arconix.pl().getApi().format().formatText("&7to the kit functions."));
allmeta.setLore(lore); allmeta.setLore(lore);
} }
alli.setItemMeta(allmeta); alli.setItemMeta(allmeta);
i.setItem(49, alli); i.setItem(50, alli);
} }
public void getInvItems(Player player, KitEditorPlayerData playerData) { public void getInvItems(Player player, KitEditorPlayerData playerData) {
@ -241,6 +269,16 @@ public class KitEditor {
alli.setItemMeta(allmeta); alli.setItemMeta(allmeta);
player.getInventory().setItem(14, alli); player.getInventory().setItem(14, alli);
alli = new ItemStack(Material.CHEST, 1);
allmeta = alli.getItemMeta();
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&6Kit Animation"));
lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &6" + playerData.getKit().getKitAnimation().name()));
allmeta.setLore(lore);
alli.setItemMeta(allmeta);
player.getInventory().setItem(17, alli);
} }
public void selling(Player player) { public void selling(Player player) {
@ -322,6 +360,25 @@ public class KitEditor {
i.setItem(13, alli); i.setItem(13, alli);
alli = new ItemStack(Material.DIAMOND_HELMET);
allmeta = alli.getItemMeta();
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&a&lSet kit link"));
lore = new ArrayList<>();
if (kit.getLink() != null)
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &a" + kit.getLink() + "&7."));
else
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &cNot set&7."));
lore.add(Arconix.pl().getApi().format().formatText(""));
lore.add(Arconix.pl().getApi().format().formatText("&7Clicking this option will"));
lore.add(Arconix.pl().getApi().format().formatText("&7allow you to set a link"));
lore.add(Arconix.pl().getApi().format().formatText("&7that players will receive"));
lore.add(Arconix.pl().getApi().format().formatText("&7when attempting to purchase"));
lore.add(Arconix.pl().getApi().format().formatText("&7this kit."));
allmeta.setLore(lore);
alli.setItemMeta(allmeta);
i.setItem(13, alli);
alli = new ItemStack(Material.DIAMOND_HELMET); alli = new ItemStack(Material.DIAMOND_HELMET);
allmeta = alli.getItemMeta(); allmeta = alli.getItemMeta();
allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&a&lSet kit price")); allmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&a&lSet kit price"));
@ -602,6 +659,20 @@ public class KitEditor {
} }
} }
public void changeAnimation(Player player) {
KitEditorPlayerData playerData = getDataFor(player);
Kit kit = playerData.getKit();
if (kit.getKitAnimation() == KitAnimation.NONE) {
kit.setKitAnimation(KitAnimation.CSGO);
} else {
kit.setKitAnimation(KitAnimation.NONE);
}
getInvItems(player, playerData);
}
public void createMoney(Player player) { public void createMoney(Player player) {
try { try {
@ -643,7 +714,10 @@ public class KitEditor {
items = Arrays.copyOf(items, items.length - 10); items = Arrays.copyOf(items, items.length - 10);
kit.saveKit(Arrays.asList(items)); kit.saveKit(Arrays.asList(items));
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Changes to &a" + kit.getShowableName() + " &8saved successfully.")); if (!playerData.isMuteSave())
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Changes to &a" + kit.getShowableName() + " &8saved successfully."));
playerData.setMuteSave(false);
} catch (Exception ex) { } catch (Exception ex) {
Debugger.runReport(ex); Debugger.runReport(ex);
} }

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatekits.kit.object; package com.songoda.ultimatekits.editor;
import com.songoda.ultimatekits.kit.Kit;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Arrays; import java.util.Arrays;
@ -10,6 +11,8 @@ public class KitEditorPlayerData {
private EditorType editorType = EditorType.NOTIN; private EditorType editorType = EditorType.NOTIN;
private ItemStack[] inventory = new ItemStack[0]; private ItemStack[] inventory = new ItemStack[0];
private boolean showInventory = false; private boolean showInventory = false;
private boolean showFuctions = false;
private boolean muteSave = false;
public Kit getKit() { public Kit getKit() {
return kit; return kit;
@ -27,9 +30,24 @@ public class KitEditorPlayerData {
this.editorType = editorType; this.editorType = editorType;
} }
public boolean isMuteSave() {
return muteSave;
}
public void setMuteSave(boolean muteSave) {
this.muteSave = muteSave;
}
public boolean isInInventory() { public boolean isInInventory() {
return showInventory; return showInventory;
} }
public boolean isInFuction() {
return showFuctions;
}
public void setInFunction(boolean showFuctions) {
this.showFuctions = showFuctions;
}
public void setInInventory(boolean showInventory) { public void setInInventory(boolean showInventory) {
this.showInventory = showInventory; this.showInventory = showInventory;

View File

@ -2,8 +2,8 @@ package com.songoda.ultimatekits.events;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitBlockData; import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;

View File

@ -3,9 +3,9 @@ package com.songoda.ultimatekits.events;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.KitEditor; import com.songoda.ultimatekits.editor.KitEditor;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitEditorPlayerData; import com.songoda.ultimatekits.editor.KitEditorPlayerData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -106,7 +106,7 @@ public class ChatListeners implements Listener {
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Command &5" + msg + "&8 has been added to your kit.")); player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Command &5" + msg + "&8 has been added to your kit."));
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN); playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
edit.openOverview(kit, player, false, parseStack); edit.openOverview(kit, player, false, parseStack, 0);
break; break;
case MONEY: case MONEY:
ItemStack parseStack2 = new ItemStack(Material.PAPER, 1); ItemStack parseStack2 = new ItemStack(Material.PAPER, 1);
@ -125,7 +125,7 @@ public class ChatListeners implements Listener {
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Money &5$" + msg + "&8 has been added to your kit.")); player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Money &5$" + msg + "&8 has been added to your kit."));
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN); playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
edit.openOverview(kit, player, false, parseStack2); edit.openOverview(kit, player, false, parseStack2, 0);
break; break;
default: default:
e.setCancelled(false); e.setCancelled(false);

View File

@ -3,9 +3,9 @@ package com.songoda.ultimatekits.events;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitBlockData; import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.kit.object.KitType; import com.songoda.ultimatekits.kit.KitType;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;

View File

@ -3,12 +3,12 @@ package com.songoda.ultimatekits.events;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.BlockEditor; import com.songoda.ultimatekits.editor.BlockEditor;
import com.songoda.ultimatekits.kit.KitEditor; import com.songoda.ultimatekits.editor.KitEditor;
import com.songoda.ultimatekits.kit.KitsGUI; import com.songoda.ultimatekits.kit.KitsGUI;
import com.songoda.ultimatekits.kit.object.BlockEditorPlayerData; import com.songoda.ultimatekits.editor.BlockEditorPlayerData;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitEditorPlayerData; import com.songoda.ultimatekits.editor.KitEditorPlayerData;
import com.songoda.ultimatekits.player.PlayerData; import com.songoda.ultimatekits.player.PlayerData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -32,8 +32,10 @@ public class InventoryListeners implements Listener {
try { try {
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
PlayerData playerData = instance.getPlayerDataManager().getPlayerAction(player); PlayerData playerData = instance.getPlayerDataManager().getPlayerAction(player);
if (playerData.getGuiLocation() == PlayerData.GUILocation.BUY_FINAL) { if (playerData.isInCrate()) {
event.setCancelled(true);
} else if (playerData.getGuiLocation() == PlayerData.GUILocation.BUY_FINAL) {
if (event.getSlot() == 11) { if (event.getSlot() == 11) {
Kit kit = playerData.getInKit(); Kit kit = playerData.getInKit();
kit.buyWithEconomy(player); kit.buyWithEconomy(player);
@ -64,7 +66,6 @@ public class InventoryListeners implements Listener {
return; return;
} }
System.out.println(clicked.getItemMeta().getDisplayName());
String kitName = clicked.getItemMeta().getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "").split(":")[0]; String kitName = clicked.getItemMeta().getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "").split(":")[0];
Kit kit = instance.getKitManager().getKit(kitName); Kit kit = instance.getKitManager().getKit(kitName);
@ -144,7 +145,7 @@ public class InventoryListeners implements Listener {
edit.decor(player); edit.decor(player);
break; break;
case 15: case 15:
instance.getKitEditor().openOverview(instance.getBlockEditor().getDataFor(player).getKit(), player, true, null); instance.getKitEditor().openOverview(instance.getBlockEditor().getDataFor(player).getKit(), player, true, null, 0);
break; break;
} }
} else if (instance.getBlockEditor().getDataFor(player).getEditorType() == BlockEditorPlayerData.EditorType.DECOR) { } else if (instance.getBlockEditor().getDataFor(player).getEditorType() == BlockEditorPlayerData.EditorType.DECOR) {
@ -178,6 +179,19 @@ public class InventoryListeners implements Listener {
KitEditor edit = instance.getKitEditor(); KitEditor edit = instance.getKitEditor();
if (instance.getKitEditor().getDataFor(player).getEditorType() == KitEditorPlayerData.EditorType.OVERVIEW) { if (instance.getKitEditor().getDataFor(player).getEditorType() == KitEditorPlayerData.EditorType.OVERVIEW) {
KitEditorPlayerData editorData = edit.getDataFor(player); KitEditorPlayerData editorData = edit.getDataFor(player);
if ((event.getSlot() > 9 && event.getSlot() < 44) && event.getSlot() != 17 && event.getSlot() != 36) {
if (event.getCurrentItem().getType() != Material.AIR) {
if (editorData.isInFuction()) {
if (event.isShiftClick()) {
editorData.setMuteSave(true);
edit.openOverview(edit.getDataFor(player).getKit(), player, false, null, event.getSlot());
editorData.setMuteSave(true);
edit.openOverview(edit.getDataFor(player).getKit(), player, false, null, event.getSlot());
}
event.setCancelled(true);
}
}
}
if ((event.getSlot() < 10 || event.getSlot() > 43) || event.getSlot() == 17 || event.getSlot() == 36) { if ((event.getSlot() < 10 || event.getSlot() > 43) || event.getSlot() == 17 || event.getSlot() == 36) {
if (event.getInventory() != null && event.getInventory().getType() == InventoryType.CHEST) { if (event.getInventory() != null && event.getInventory().getType() == InventoryType.CHEST) {
event.setCancelled(true); event.setCancelled(true);
@ -203,11 +217,14 @@ public class InventoryListeners implements Listener {
case 14: case 14:
edit.createMoney(player); edit.createMoney(player);
break; break;
case 17:
edit.changeAnimation(player);
break;
} }
} }
} }
if (event.getSlot() == 49) { if (event.getSlot() == 50) {
if (!editorData.isInInventory()) { if (!editorData.isInInventory()) {
player.getInventory().setContents(editorData.getInventory()); player.getInventory().setContents(editorData.getInventory());
editorData.setInInventory(true); editorData.setInInventory(true);
@ -215,6 +232,11 @@ public class InventoryListeners implements Listener {
} else edit.getInvItems(player, editorData); } else edit.getInvItems(player, editorData);
edit.updateInvButton(event.getInventory(), editorData); edit.updateInvButton(event.getInventory(), editorData);
} }
if (event.getSlot() == 48) {
editorData.setInFunction(!editorData.isInFuction());
editorData.setMuteSave(true);
edit.openOverview(edit.getDataFor(player).getKit(), player, false, null, 0);
}
} else if (instance.getKitEditor().getDataFor(player).getEditorType() == KitEditorPlayerData.EditorType.SELLING) { } else if (instance.getKitEditor().getDataFor(player).getEditorType() == KitEditorPlayerData.EditorType.SELLING) {
event.setCancelled(true); event.setCancelled(true);
switch (event.getSlot()) { switch (event.getSlot()) {
@ -270,7 +292,7 @@ public class InventoryListeners implements Listener {
if (event.getInventory().getTitle().contains("You are editing kit")) { if (event.getInventory().getTitle().contains("You are editing kit")) {
instance.getBlockEditor().openOverview(player, instance.getBlockEditor().getDataFor(player).getLocation()); instance.getBlockEditor().openOverview(player, instance.getBlockEditor().getDataFor(player).getLocation());
} else { } else {
edit.openOverview(edit.getDataFor(player).getKit(), player, false, null); edit.openOverview(edit.getDataFor(player).getKit(), player, false, null, 0);
} }
} }
} }

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatekits.events; package com.songoda.ultimatekits.events;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.BlockEditorPlayerData; import com.songoda.ultimatekits.editor.BlockEditorPlayerData;
import com.songoda.ultimatekits.kit.object.KitEditorPlayerData; import com.songoda.ultimatekits.editor.KitEditorPlayerData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatekits.handlers; package com.songoda.ultimatekits.handlers;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitBlockData; import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -45,7 +45,7 @@ public class DisplayItemHandler {
Kit kit = kitBlockData.getKit(); Kit kit = kitBlockData.getKit();
List<ItemStack> list = kit.getReadableContents(null, false); List<ItemStack> list = kit.getReadableContents(null, false, false);
for (Entity e : location.getChunk().getEntities()) { for (Entity e : location.getChunk().getEntities()) {
if (e.getType() != EntityType.DROPPED_ITEM if (e.getType() != EntityType.DROPPED_ITEM
|| e.getLocation().getX() != location.getX() || e.getLocation().getX() != location.getX()

View File

@ -3,9 +3,9 @@ package com.songoda.ultimatekits.handlers;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.object.KitBlockData; import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.kit.object.KitType; import com.songoda.ultimatekits.kit.KitType;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatekits.handlers; package com.songoda.ultimatekits.handlers;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.KitBlockData; import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -2,7 +2,7 @@ package com.songoda.ultimatekits.key;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;

View File

@ -1,12 +1,18 @@
package com.songoda.ultimatekits.kit.object; package com.songoda.ultimatekits.kit;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.key.Key; import com.songoda.ultimatekits.key.Key;
import com.songoda.ultimatekits.kit.type.KitContentCommand;
import com.songoda.ultimatekits.kit.type.KitContentEconomy;
import com.songoda.ultimatekits.kit.type.KitContentItem;
import com.songoda.ultimatekits.player.PlayerData; import com.songoda.ultimatekits.player.PlayerData;
import com.songoda.ultimatekits.tasks.CrateAnimateTask;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods; import com.songoda.ultimatekits.utils.Methods;
import me.clip.placeholderapi.PlaceholderAPI;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -21,11 +27,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
/** /**
* Created by songoda on 2/24/2017. * Created by songoda on 2/24/2017.
@ -43,13 +45,16 @@ public class Kit {
private Material displayItem; private Material displayItem;
private List<String> contents; private List<KitItem> contents;
public Kit(String name, String title, String link, double price, Material displayItem, int delay, boolean hidden, List<String> contents) { private KitAnimation kitAnimation;
public Kit(String name, String title, String link, double price, Material displayItem, int delay, boolean hidden, List<KitItem> contents, KitAnimation kitAnimation) {
this.name = name; this.name = name;
this.showableName = Arconix.pl().getApi().format().formatText(name, true); this.showableName = Arconix.pl().getApi().format().formatText(name, true);
this.price = price; this.price = price;
this.link = link; this.link = link;
this.kitAnimation = kitAnimation;
this.title = title; this.title = title;
this.delay = delay; this.delay = delay;
this.hidden = hidden; this.hidden = hidden;
@ -58,7 +63,7 @@ public class Kit {
} }
public Kit(String name) { public Kit(String name) {
this(name, null, null, 0, null, 0, false, new ArrayList<>()); this(name, null, null, 0, null, 0, false, new ArrayList<>(), KitAnimation.NONE);
} }
public void buy(Player p) { public void buy(Player p) {
@ -90,9 +95,9 @@ public class Kit {
private List<ItemStack> getItemContents() { private List<ItemStack> getItemContents() {
List<ItemStack> items = new ArrayList<>(); List<ItemStack> items = new ArrayList<>();
for (String str : this.getContents()) { for (KitItem item : this.getContents()) {
if ((!str.startsWith("/") && !str.startsWith("$"))) if (item.getContent() instanceof KitContentItem)
items.add(Methods.deserializeItemStack(str)); items.add(((KitContentItem) item.getContent()).getItemStack());
} }
return items; return items;
} }
@ -118,51 +123,53 @@ public class Kit {
return space >= spaceNeeded; return space >= spaceNeeded;
} }
public void give(Player p, boolean useKey, boolean economy, boolean console) { public void give(Player player, boolean useKey, boolean economy, boolean console) {
try { try {
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Prevent The Redeeming of a Kit When Inventory Is Full") && !hasRoom(p, useKey)) { if (UltimateKits.getInstance().getConfig().getBoolean("Main.Prevent The Redeeming of a Kit When Inventory Is Full") && !hasRoom(player, useKey)) {
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.INVENTORY_FULL.getConfigValue())); player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.INVENTORY_FULL.getConfigValue()));
return; return;
} }
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Sounds Enabled")) { if (UltimateKits.getInstance().getConfig().getBoolean("Main.Sounds Enabled") && kitAnimation == KitAnimation.NONE) {
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F); player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
} }
if (useKey) { if (useKey) {
if (p.getItemInHand().getType() != Material.TRIPWIRE_HOOK || !p.getItemInHand().hasItemMeta()) { if (player.getItemInHand().getType() != Material.TRIPWIRE_HOOK || !player.getItemInHand().hasItemMeta()) {
return; return;
} }
Key key = UltimateKits.getInstance().getKeyManager().getKey(ChatColor.stripColor(p.getItemInHand().getItemMeta().getLore().get(0)).replace(" Key", "")); Key key = UltimateKits.getInstance().getKeyManager().getKey(ChatColor.stripColor(player.getItemInHand().getItemMeta().getLore().get(0)).replace(" Key", ""));
if (!p.getItemInHand().getItemMeta().getDisplayName().equals(Lang.KEY_TITLE.getConfigValue(showableName)) && !p.getItemInHand().getItemMeta().getDisplayName().equals(Lang.KEY_TITLE.getConfigValue("All"))) { if (!player.getItemInHand().getItemMeta().getDisplayName().equals(Lang.KEY_TITLE.getConfigValue(showableName)) && !player.getItemInHand().getItemMeta().getDisplayName().equals(Lang.KEY_TITLE.getConfigValue("Any"))) {
p.sendMessage(Arconix.pl().getApi().format().formatText(UltimateKits.getInstance().references.getPrefix() + Lang.WRONG_KEY.getConfigValue())); player.sendMessage(Arconix.pl().getApi().format().formatText(UltimateKits.getInstance().references.getPrefix() + Lang.WRONG_KEY.getConfigValue()));
return; return;
} }
for (int i = 0; i < key.getKitAmount(); i++) for (int i = 0; i < key.getKitAmount(); i++)
givePartKit(p, key); givePartKit(player, key);
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.KEY_SUCCESS.getConfigValue(showableName))); player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.KEY_SUCCESS.getConfigValue(showableName)));
if (p.getInventory().getItemInHand().getAmount() != 1) { if (player.getInventory().getItemInHand().getAmount() != 1) {
ItemStack is = p.getItemInHand(); ItemStack is = player.getItemInHand();
is.setAmount(is.getAmount() - 1); is.setAmount(is.getAmount() - 1);
p.setItemInHand(is); player.setItemInHand(is);
} else { } else {
p.setItemInHand(null); player.setItemInHand(null);
} }
return; return;
} }
if (getNextUse(p) == -1 && !economy && !console) { if (getNextUse(player) == -1 && !economy && !console) {
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName))); player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
} else if (getNextUse(p) <= 0 || economy || console) { } else if (getNextUse(player) <= 0 || economy || console) {
giveKit(p); giveKit(player);
if (economy) { if (economy) {
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.PURCHASE_SUCCESS.getConfigValue(showableName))); player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.PURCHASE_SUCCESS.getConfigValue(showableName)));
} else { } else {
updateDelay(p); updateDelay(player);
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.GIVE_SUCCESS.getConfigValue(showableName))); if (kitAnimation == KitAnimation.NONE) {
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.GIVE_SUCCESS.getConfigValue(showableName)));
}
} }
} else { } else {
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(p))))); player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(player)))));
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -195,7 +202,7 @@ public class Kit {
guititle = Arconix.pl().getApi().format().formatText(guititle); guititle = Arconix.pl().getApi().format().formatText(guititle);
List<ItemStack> list = getReadableContents(p, true); List<ItemStack> list = getReadableContents(p, true, false);
int amt = 0; int amt = 0;
for (ItemStack is : list) { for (ItemStack is : list) {
@ -368,21 +375,32 @@ public class Kit {
public void saveKit(List<ItemStack> items) { public void saveKit(List<ItemStack> items) {
try { try {
List<String> list = new ArrayList<>(); List<KitItem> list = new ArrayList<>();
for (ItemStack is : items) { for (ItemStack is : items) {
if (is != null && is.getType() != null && is.getType() != Material.AIR) { if (is != null && is.getType() != null && is.getType() != Material.AIR) {
if (is.getType() == Material.PAPER && ChatColor.stripColor(is.getItemMeta().getDisplayName()).equals("Command")) {
if (is.getItemMeta().hasLore()) {
ItemMeta meta = is.getItemMeta();
List<String> newLore = new ArrayList<>();
for (String line : meta.getLore()) {
if (line.equals(TextComponent.convertToInvisibleString("----"))) break;
newLore.add(line);
}
meta.setLore(newLore);
is.setItemMeta(meta);
}
if (is.getType() == Material.PAPER && ChatColor.stripColor(is.getItemMeta().getDisplayName()).endsWith("Command")) {
StringBuilder command = new StringBuilder(); StringBuilder command = new StringBuilder();
for (String line : is.getItemMeta().getLore()) { for (String line : is.getItemMeta().getLore()) {
command.append(line); command.append(line);
} }
list.add(ChatColor.stripColor(command.toString())); list.add(new KitItem(ChatColor.stripColor(command.toString())));
} else if (is.getType() == Material.PAPER && ChatColor.stripColor(is.getItemMeta().getDisplayName()).equals("Money")) { } else if (is.getType() == Material.PAPER && ChatColor.stripColor(is.getItemMeta().getDisplayName()).endsWith("Money")) {
String money = is.getItemMeta().getLore().get(0); String money = is.getItemMeta().getLore().get(0);
list.add(ChatColor.stripColor(money)); list.add(new KitItem(ChatColor.stripColor(money)));
} else { } else {
String serialized = Methods.serializeItemStack(is); list.add(new KitItem(is));
list.add(serialized);
} }
} }
} }
@ -393,43 +411,19 @@ public class Kit {
} }
public List<ItemStack> getReadableContents(Player player, boolean commands) { public List<ItemStack> getReadableContents(Player player, boolean commands, boolean moveable) {
List<ItemStack> stacks = new ArrayList<>(); List<ItemStack> stacks = new ArrayList<>();
try { try {
for (String str : getContents()) { for (KitItem item : getContents()) {
if ((!str.startsWith("/") && !str.startsWith("$")) || commands) { if ((!item.getSerialized().startsWith("/") && !item.getSerialized().startsWith(UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol"))) || commands) { //ToDO: I doubt this is correct.
ItemStack parseStack; ItemStack stack = moveable ? item.getMoveableItem() : item.getItem();
if (str.startsWith("$")) {
parseStack = new ItemStack(Material.PAPER, 1);
ItemMeta meta = parseStack.getItemMeta();
ArrayList<String> lore = new ArrayList<>();
lore.add("§a" + str.trim());
meta.setLore(lore);
meta.setDisplayName(Lang.MONEY.getConfigValue());
parseStack.setItemMeta(meta);
} else if (str.startsWith("/")) {
parseStack = new ItemStack(Material.PAPER, 1);
ItemMeta meta = parseStack.getItemMeta();
ArrayList<String> lore = new ArrayList<>(); ItemStack fin = stack;
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI") && stack.getItemMeta().getLore() != null) {
int index = 0;
while (index < str.length()) {
lore.add(Arconix.pl().getApi().format().formatText("&a" + str.substring(index, Math.min(index + 30, str.length()))));
index += 30;
}
meta.setLore(lore);
meta.setDisplayName(Lang.COMMAND.getConfigValue());
parseStack.setItemMeta(meta);
} else {
parseStack = Methods.deserializeItemStack(str);
}
ItemStack fin = parseStack;
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI") && parseStack.getItemMeta().getLore() != null) {
ArrayList<String> lore2 = new ArrayList<>(); ArrayList<String> lore2 = new ArrayList<>();
ItemMeta meta2 = parseStack.getItemMeta(); ItemMeta meta2 = stack.getItemMeta();
for (String lor : parseStack.getItemMeta().getLore()) { for (String lor : stack.getItemMeta().getLore()) {
lor = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, lor.replace(" ", "_")).replace("_", " "); lor = PlaceholderAPI.setPlaceholders(player, lor.replace(" ", "_")).replace("_", " ");
lore2.add(lor); lore2.add(lor);
} }
meta2.setLore(lore2); meta2.setLore(lore2);
@ -454,45 +448,59 @@ public class Kit {
public void givePartKit(Player player, Key key) { public void givePartKit(Player player, Key key) {
try { try {
List<KitItem> innerContents = new ArrayList<>(getContents());
List<String> innerContents = new ArrayList<>(getContents()); Collections.shuffle(innerContents);
int amt = innerContents.size(); int amt = innerContents.size();
int amtToGive = key == null ? amt : key.getAmt();
if (key != null && key.getAmt() != -1 && key.getAmt() < innerContents.size()) { int num = 0;
amt = innerContents.size() - key.getAmt(); for (KitItem item : innerContents) {
} if (amtToGive == 0) continue;
int ch = item.getChance() == 0 ? 100 : item.getChance();
while (key != null && amt != 0 && key.getAmt() != -1) { double rand = Math.random() * 100;
int num = ThreadLocalRandom.current().nextInt(0, innerContents.size()); if (rand - ch < 0 || ch == 100) {
innerContents.remove(num); if (item.getContent() instanceof KitContentEconomy) {
amt--; try {
} Methods.pay(player, ((KitContentEconomy) item.getContent()).getAmount());
for (String line : innerContents) { player.sendMessage(Lang.ECO_SENT.getConfigValue(Arconix.pl().getApi().format().formatEconomy(((KitContentEconomy) item.getContent()).getAmount())));
if (line.startsWith("$")) { } catch (NumberFormatException ex) {
try { Debugger.runReport(ex);
Methods.pay(player, Double.parseDouble(line.substring("$".length()).trim())); }
player.sendMessage(Lang.ECO_SENT.getConfigValue(Arconix.pl().getApi().format().formatEconomy(Double.parseDouble(line.substring("$".length()).trim())))); amtToGive --;
} catch (NumberFormatException ex) { continue;
Debugger.runReport(ex); } else if (item.getContent() instanceof KitContentCommand) {
String parsed = ((KitContentCommand) item.getContent()).getCommand();
parsed = parsed.replace("{player}", player.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), parsed);
amtToGive --;
continue;
} }
continue;
} else if (line.startsWith("/")) { ItemStack parseStack = ((KitContentItem)item.getContent()).getItemStack();
String parsed = line.substring(1); if (parseStack.getType() == Material.AIR) continue;
parsed = parsed.replace("{player}", player.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), parsed); // Not proud of this.
continue; amtToGive --;
}
if (kitAnimation != KitAnimation.NONE) {
ItemStack parseStack = Methods.deserializeItemStack(line); Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(),
if (parseStack.getType() == Material.AIR) continue; () -> new CrateAnimateTask(UltimateKits.getInstance(), player, this, item.getItem()), 210 * num);
} else {
Map<Integer, ItemStack> overfilled = player.getInventory().addItem(parseStack); Map<Integer, ItemStack> overfilled = player.getInventory().addItem(item.getItem());
for (ItemStack item2 : overfilled.values()) {
player.getWorld().dropItemNaturally(player.getLocation(), item2);
for (ItemStack item : overfilled.values()) { }
player.getWorld().dropItemNaturally(player.getLocation(), item); }
num ++;
} }
} }
if (kitAnimation != KitAnimation.NONE) {
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(),
() -> {
UltimateKits.getInstance().getPlayerDataManager().getPlayerAction(player).setInCrate(false);
player.closeInventory();
}, (210 * num) + 20);
}
player.updateInventory(); player.updateInventory();
} catch (Exception e) { } catch (Exception e) {
@ -660,11 +668,11 @@ public class Kit {
this.delay = delay; this.delay = delay;
} }
public List<String> getContents() { public List<KitItem> getContents() {
return this.contents; return this.contents;
} }
public void setContents(List<String> contents) { public void setContents(List<KitItem> contents) {
this.contents = contents; this.contents = contents;
} }
@ -692,6 +700,14 @@ public class Kit {
this.hidden = hidden; this.hidden = hidden;
} }
public KitAnimation getKitAnimation() {
return kitAnimation;
}
public void setKitAnimation(KitAnimation kitAnimation) {
this.kitAnimation = kitAnimation;
}
@Override @Override
public int hashCode() { public int hashCode() {
return 31 * (name != null ? name.hashCode() : 0); return 31 * (name != null ? name.hashCode() : 0);

View File

@ -0,0 +1,5 @@
package com.songoda.ultimatekits.kit;
public enum KitAnimation {
NONE, CSGO
}

View File

@ -1,4 +1,4 @@
package com.songoda.ultimatekits.kit.object; package com.songoda.ultimatekits.kit;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -0,0 +1,95 @@
package com.songoda.ultimatekits.kit;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.api.methods.math.AMath;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.type.KitContent;
import com.songoda.ultimatekits.kit.type.KitContentCommand;
import com.songoda.ultimatekits.kit.type.KitContentEconomy;
import com.songoda.ultimatekits.kit.type.KitContentItem;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class KitItem {
private final KitContent content;
private int chance = 0;
public KitItem(String item) {
String item2 = item.replace(String.valueOf(ChatColor.COLOR_CHAR), "");
if (item2.substring(0, Math.min(item2.length(), 5)).contains(":")) {
this.chance = Integer.parseInt(item2.split(":", 2)[0]);
item = item.split(":", 2)[1].trim();
}
if (item.startsWith(UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol"))) {
this.content = new KitContentEconomy(Double.parseDouble(item.substring(1).trim()));
} else if (item.startsWith("/")) {
this.content = new KitContentCommand(item.substring(1));
} else {
this.content = new KitContentItem(Methods.deserializeItemStack(item));
}
}
public KitItem(ItemStack item) {
ItemStack itemStack = item.clone();
ItemMeta meta = itemStack.getItemMeta();
if (meta.getDisplayName().contains(":")) {
String[] split = meta.getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "").split(":", 2);
if (AMath.isInt(split[0])) {
this.chance = Integer.parseInt(split[0]);
meta.setDisplayName(split[1].contains("aqf") ? null : meta.getDisplayName().split(":", 2)[1]);
itemStack.setItemMeta(meta);
}
}
String name = meta.hasDisplayName() ? meta.getDisplayName() : "";
if (name.startsWith(UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol"))) {
this.content = new KitContentEconomy(Double.parseDouble(name.substring(1).trim()));
} else if (name.startsWith("/")) {
this.content = new KitContentCommand(name.substring(1));
} else {
this.content = new KitContentItem(itemStack);
}
}
public KitContent getContent() {
return content;
}
public String getSerialized() {
if (chance == 0) return this.content.getSerialized();
return chance + ":" + this.content.getSerialized();
}
public int getChance() {
return chance == 0 ? 100 : chance;
}
public void setChance(int chance) {
this.chance = chance;
}
public ItemStack getItem() {
return content.getItemForDisplay();
}
public ItemStack getMoveableItem() {
ItemStack item = content.getItemForDisplay();
ItemMeta meta = item.getItemMeta();
if (chance != 0) meta.setDisplayName(meta.hasDisplayName() ? TextComponent.convertToInvisibleString(chance + ":") + meta.getDisplayName() : TextComponent.convertToInvisibleString(chance + ":aqf") + item.getType().name().replace("_", " "));
item.setItemMeta(meta);
return item;
}
@Override
public String toString() {
return "KitItem:{"
+ "Item:\"" + content.getSerialized() + "\","
+ "Chance:" + chance
+ "}";
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.ultimatekits.kit.object; package com.songoda.ultimatekits.kit;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -1,3 +1,3 @@
package com.songoda.ultimatekits.kit.object; package com.songoda.ultimatekits.kit;
public enum KitType {PREVIEW, CRATE, CLAIM} public enum KitType {PREVIEW, CRATE, CLAIM}

View File

@ -4,7 +4,6 @@ import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix; import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang; import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits; import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.object.Kit;
import com.songoda.ultimatekits.player.PlayerData; import com.songoda.ultimatekits.player.PlayerData;
import com.songoda.ultimatekits.utils.Debugger; import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods; import com.songoda.ultimatekits.utils.Methods;

View File

@ -0,0 +1,11 @@
package com.songoda.ultimatekits.kit.type;
import org.bukkit.inventory.ItemStack;
public interface KitContent {
String getSerialized();
ItemStack getItemForDisplay();
}

View File

@ -0,0 +1,43 @@
package com.songoda.ultimatekits.kit.type;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.Lang;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
public class KitContentCommand implements KitContent {
private String command; // Stored like "eco give <player> 100"
public KitContentCommand(String command) {
this.command = command;
}
public String getCommand() {
return command;
}
@Override
public String getSerialized() {
return "/" + command;
}
@Override
public ItemStack getItemForDisplay() {
ItemStack stack = new ItemStack(Material.PAPER, 1);
ItemMeta meta = stack.getItemMeta();
ArrayList<String> lore = new ArrayList<>();
int index = 0;
while (index < command.length()) {
lore.add(TextComponent.formatText("&a" + (index == 0 ? "/" : "") + "&a" + command.substring(index, Math.min(index + 30, command.length()))));
index += 30;
}
meta.setLore(lore);
meta.setDisplayName(Lang.COMMAND.getConfigValue());
stack.setItemMeta(meta);
return stack;
}
}

View File

@ -0,0 +1,46 @@
package com.songoda.ultimatekits.kit.type;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
public class KitContentEconomy implements KitContent {
private double amount;
public KitContentEconomy(double amount) {
this.amount = amount;
}
public double getAmount() {
return amount;
}
@Override
public String getSerialized() {
return UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol") + amount;
}
@Override
public ItemStack getItemForDisplay() {
ItemStack parseStack = new ItemStack(Material.PAPER, 1);
ItemMeta meta = parseStack.getItemMeta();
ArrayList<String> lore = new ArrayList<>();
int index = 0;
while (index < String.valueOf(amount).length()) {
lore.add(TextComponent.formatText("&a" + (index == 0 ? UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol") : "") + "&a" + String.valueOf(amount).substring(index, Math.min(index + 30, String.valueOf(amount).length()))));
index += 30;
}
meta.setLore(lore);
meta.setDisplayName(Lang.MONEY.getConfigValue());
parseStack.setItemMeta(meta);
return parseStack;
}
}

View File

@ -0,0 +1,27 @@
package com.songoda.ultimatekits.kit.type;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.inventory.ItemStack;
public class KitContentItem implements KitContent {
private ItemStack itemStack;
public KitContentItem(ItemStack itemStack) {
this.itemStack = itemStack;
}
public ItemStack getItemStack() {
return itemStack;
}
@Override
public String getSerialized() {
return Methods.serializeItemStack(itemStack);
}
@Override
public ItemStack getItemForDisplay() {
return itemStack.clone();
}
}

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatekits.player; package com.songoda.ultimatekits.player;
import com.songoda.ultimatekits.kit.object.Kit; import com.songoda.ultimatekits.kit.Kit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -10,6 +10,8 @@ public class PlayerData {
public enum GUILocation { NOT_IN, BUY_FINAL, KITS, DISPLAY } public enum GUILocation { NOT_IN, BUY_FINAL, KITS, DISPLAY }
private boolean isInCrate = false;
private final UUID playerUUID; private final UUID playerUUID;
private boolean kitMode; private boolean kitMode;
private Kit inKit = null; private Kit inKit = null;
@ -55,4 +57,12 @@ public class PlayerData {
public void setGuiLocation(GUILocation guiLocation) { public void setGuiLocation(GUILocation guiLocation) {
this.guiLocation = guiLocation; this.guiLocation = guiLocation;
} }
public boolean isInCrate() {
return isInCrate;
}
public void setInCrate(boolean inCrate) {
isInCrate = inCrate;
}
} }

View File

@ -0,0 +1,122 @@
package com.songoda.ultimatekits.tasks;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.api.methods.inventory.AInventory;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitItem;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.*;
public class CrateAnimateTask extends BukkitRunnable {
private CrateAnimateTask instance;
private final UltimateKits plugin;
private final Player player;
private final Inventory inventory;
private final ArrayDeque<KitItem> items;
private final ItemStack give;
private boolean slow = false;
private boolean finish = false;
private boolean done = false;
public CrateAnimateTask(UltimateKits plugin, Player player, Kit kit, ItemStack give) {
this.plugin = plugin;
this.player = player;
this.give = give;
this.inventory = Bukkit.createInventory(null, 27, TextComponent.formatText(kit.getShowableName()));
plugin.getPlayerDataManager().getPlayerAction(player).setInCrate(true);
List<KitItem> items = kit.getContents();
Collections.shuffle(items);
this.items = new ArrayDeque<>(items);
while (this.items.size() < 10) {
for (KitItem item : items) {
if (this.items.size() < 10)
this.items.addLast(item);
}
}
instance = this;
instance.runTaskTimer(plugin, 0, 3);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
slow = true;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> finish = true, 20);
}, 130);
}
private int num = 0;
@Override
public void run() {
if (slow && num == 1) {
num = 0;
return;
}
num = slow ? 1 : 0;
for (int i = 0; i < 27; i ++) {
inventory.setItem(i, AInventory.toGlass(true, 0));
}
for (int i = 9; i < 18; i ++) {
inventory.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
inventory.setItem(4, new ItemStack(Material.TRIPWIRE_HOOK));
inventory.setItem(22, new ItemStack(Material.TRIPWIRE_HOOK));
if (!done) {
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 5f, 5f);
this.items.addFirst(this.items.getLast());
this.items.removeLast();
}
List<KitItem> items = new ArrayList<>(this.items);
for (int i = 0; i < 9; i ++) {
inventory.setItem(9 + i, items.get(i).getItem());
}
if (finish) {
if (inventory.getItem(13).isSimilar(give)) {
if (!done) {
Map<Integer, ItemStack> overfilled = player.getInventory().addItem(give);
for (ItemStack item2 : overfilled.values()) {
player.getWorld().dropItemNaturally(player.getLocation(), item2);
}
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 10f, 10f);
player.sendMessage(plugin.references.getPrefix() + TextComponent.formatText(Lang.CRATE_WON.getConfigValue(WordUtils.capitalize(give.getType().name().toLowerCase().replace("_", " ")))));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> finish(), 50);
}
done = true;
}
}
player.openInventory(inventory);
}
private void finish() {
instance.cancel();
}
}

View File

@ -220,8 +220,9 @@ public class SettingsManager implements Listener {
o5("Dont-Preview-Commands", "Main.Dont Preview Commands In Kits", false), o5("Dont-Preview-Commands", "Main.Dont Preview Commands In Kits", false),
o6("Hologram-Layout", "Main.Hologram Layout", Arrays.asList("{TITLE}", "{LEFT-CLICK}", "{RIGHT-CLICK}")), o6("Hologram-Layout", "Main.Hologram Layout", Arrays.asList("{TITLE}", "{LEFT-CLICK}", "{RIGHT-CLICK}")),
o7("EnableSound", "Main.Sounds Enabled", true), o7("EnableSound", "Main.Sounds Enabled", true),
o8("Sound", "Main.Sound Played While Clicking In Inventories", "ENTITY_ENDERMEN_TELEPORT"), o8("Sound", "Main.Sound Played While Clicking In Inventories", "ENTITY_ENDERMAN_TELEPORT"),
o85("Sound", "Main.Prevent The Redeeming of a Kit When Inventory Is Full", true), o85("-", "Main.Prevent The Redeeming of a Kit When Inventory Is Full", true),
CURRENCY_SYMBOL("-", "Main.Currency Symbol", "$"),
o9("Exit-Icon", "Interfaces.Exit Icon", "OAK_DOOR"), o9("Exit-Icon", "Interfaces.Exit Icon", "OAK_DOOR"),
o10("Buy-Icon", "Interfaces.Buy Icon", "EMERALD"), o10("Buy-Icon", "Interfaces.Buy Icon", "EMERALD"),