mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-12-01 14:43:38 +01:00
Merge branch 'development'
This commit is contained in:
commit
e91c23d619
4
pom.xml
4
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateKits</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.6.6</version>
|
||||
<version>2.6.7</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateKits-${project.version}</finalName>
|
||||
@ -101,7 +101,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<version>1.16.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -182,7 +182,6 @@ public class UltimateKits extends SongodaPlugin {
|
||||
|
||||
displayItemHandler.start();
|
||||
particleHandler.start();
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> saveKits(false), 6000, 6000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -302,8 +301,9 @@ public class UltimateKits extends SongodaPlugin {
|
||||
for (String keyName : keyFile.getConfigurationSection("Keys").getKeys(false)) {
|
||||
int amt = keyFile.getInt("Keys." + keyName + ".Item Amount");
|
||||
int kitAmount = keyFile.getInt("Keys." + keyName + ".Amount of kit received");
|
||||
boolean enchanted = keyFile.getBoolean("Keys." + keyName + ".Enchanted");
|
||||
|
||||
Key key = new Key(keyName, amt, kitAmount);
|
||||
Key key = new Key(keyName, amt, kitAmount, enchanted);
|
||||
keyManager.addKey(key);
|
||||
}
|
||||
}
|
||||
@ -508,6 +508,7 @@ public class UltimateKits extends SongodaPlugin {
|
||||
keyFile.set("Keys.Ultra.Amount of kit received", 1);
|
||||
keyFile.set("Keys.Insane.Item Amount", -1);
|
||||
keyFile.set("Keys.Insane.Amount of kit received", 2);
|
||||
keyFile.set("Keys.Insane.Enchanted", true);
|
||||
}
|
||||
|
||||
private void checkCrateDefaults() {
|
||||
|
@ -338,7 +338,8 @@ public class KitEditorGui extends DoubleGui {
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String line : meta.getLore()) {
|
||||
if (TextUtils.convertFromInvisibleString(line).equals("----")) break;
|
||||
if (line.contains("Moveable")) continue;
|
||||
if (line.equals(TextUtils.formatText("&8----"))) break;
|
||||
newLore.add(line);
|
||||
}
|
||||
meta.setLore(newLore);
|
||||
@ -421,8 +422,9 @@ public class KitEditorGui extends DoubleGui {
|
||||
|
||||
if (meta.hasLore()) itemLore = meta.getLore();
|
||||
else itemLore = new ArrayList<>();
|
||||
itemLore.add(TextUtils.convertToInvisibleLoreString("----"));
|
||||
itemLore.add(ChatColor.GRAY.toString() + plugin.getLocale().getMessage("general.type.chance") + ": " + ChatColor.GOLD.toString() + item.getChance() + "%");
|
||||
itemLore.add(TextUtils.formatText("&8----"));
|
||||
itemLore.add(ChatColor.GRAY.toString() + plugin.getLocale().getMessage("general.type.chance").getMessage().replaceFirst("^" + ChatColor.RESET.toString(), "")
|
||||
+ ": " + ChatColor.GOLD.toString() + item.getChance() + "%"); //TODO use a placeholder message in locales
|
||||
if (isInFunction) {
|
||||
itemLore.addAll(Arrays.asList(plugin.getLocale().getMessage("interface.kiteditor.itemfunctionlore")
|
||||
.processPlaceholder("item", item.getDisplayItem() == null ? "" : item.getDisplayItem().name())
|
||||
|
@ -84,6 +84,8 @@ public class KitGeneralOptionsGui extends Gui {
|
||||
guiManager.showGUI(event.player, gui);
|
||||
} else if (event.clickType == ClickType.RIGHT) {
|
||||
kit.setCategory(null);
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitoptions.categorylore")
|
||||
.processPlaceholder("category", kit.getCategory() == null ? "none" : kit.getCategory().getName()).getMessage().split("\\|"));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -144,8 +144,7 @@ public class KitSelectorGui extends Gui {
|
||||
.processPlaceholder("kit", TextUtils.formatText(kitItem, true)).getMessage();
|
||||
|
||||
setButton(row, col, GuiUtils.createButtonItem(
|
||||
kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.ENCHANTED_BOOK,
|
||||
TextUtils.convertToInvisibleString(kitItem + ":") + kitTitle,
|
||||
kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.ENCHANTED_BOOK,kitTitle,
|
||||
getKitLore(kit)),
|
||||
event -> {
|
||||
if (event.clickType == ClickType.MIDDLE && player.hasPermission("ultimatekits.admin")) {
|
||||
|
@ -118,7 +118,7 @@ public class PreviewKitGui extends Gui {
|
||||
|| (Settings.DONT_PREVIEW_COMMANDS.getBoolean()
|
||||
&& item.getType() == Material.PAPER
|
||||
&& item.getItemMeta().hasDisplayName()
|
||||
&& item.getItemMeta().getDisplayName().equals(plugin.getLocale().getMessage("general.type.command")))) {
|
||||
&& item.getItemMeta().getDisplayName().equals(plugin.getLocale().getMessage("general.type.command").getMessage()))) {
|
||||
setItem(row, col, AIR);
|
||||
} else if (item.getAmount() <= 64) {
|
||||
// display item
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.songoda.ultimatekits.handlers;
|
||||
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
@ -15,6 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -62,7 +65,10 @@ public class DisplayItemHandler {
|
||||
|
||||
if (!kitBlockData.isDisplayingItems()) e.remove();
|
||||
|
||||
int inum = Integer.parseInt(i.getItemStack().getItemMeta().getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "")) + 1;
|
||||
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(i.getItemStack());
|
||||
int inum = nbtItem.has("num") ? nbtItem.getNBTObject("num").asInt() + 1 : 1;
|
||||
|
||||
if (inum > list.size()) inum = 1;
|
||||
|
||||
ItemStack is = list.get(inum - 1);
|
||||
@ -70,11 +76,13 @@ public class DisplayItemHandler {
|
||||
if (kit.getDisplayItem() != null)
|
||||
is = kit.getDisplayItem().getItem();
|
||||
}
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
is.setAmount(1);
|
||||
meta.setDisplayName(TextUtils.convertToInvisibleString(Integer.toString(inum)));
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
meta.setDisplayName(null);
|
||||
is.setItemMeta(meta);
|
||||
i.setItemStack(is);
|
||||
nbtItem = NmsManager.getNbt().of(is);
|
||||
nbtItem.set("num", inum);
|
||||
i.setItemStack(nbtItem.finish());
|
||||
i.setPickupDelay(9999);
|
||||
return;
|
||||
}
|
||||
@ -83,13 +91,18 @@ public class DisplayItemHandler {
|
||||
ItemStack is = list.get(0);
|
||||
is.setAmount(1);
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
meta.setDisplayName(TextUtils.convertFromInvisibleString("0"));
|
||||
meta.setLore(Collections.singletonList("Display Item"));
|
||||
is.setItemMeta(meta);
|
||||
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(is);
|
||||
nbtItem.set("num", 0);
|
||||
|
||||
Bukkit.getScheduler().runTask(instance, () -> {
|
||||
Item item = location.getWorld().dropItem(location.add(0, 1, 0), list.get(0));
|
||||
Item item = location.getWorld().dropItem(location.add(0, 1, 0), nbtItem.finish());
|
||||
Vector vec = new Vector(0, 0, 0);
|
||||
item.setVelocity(vec);
|
||||
item.setPickupDelay(9999);
|
||||
item.setCustomName(null);
|
||||
item.setMetadata("US_EXEMPT", new FixedMetadataValue(UltimateKits.getInstance(), true));
|
||||
item.setMetadata("displayItem", new FixedMetadataValue(UltimateKits.getInstance(), true));
|
||||
item.setMetadata("betterdrops_ignore", new FixedMetadataValue(UltimateKits.getInstance(), true));
|
||||
|
@ -1,57 +1,62 @@
|
||||
package com.songoda.ultimatekits.key;
|
||||
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class Key {
|
||||
|
||||
// The name of the key.
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
// The amount of items this key will give you. -1 is all;
|
||||
private int amount;
|
||||
private final int amount;
|
||||
|
||||
// Should the key be enchanted?
|
||||
private final boolean enchanted;
|
||||
|
||||
// The amount of kit given when the key is used.
|
||||
private int kitAmount;
|
||||
private final int kitAmount;
|
||||
|
||||
public Key(String name, int amount, int kitAmount) {
|
||||
public Key(String name, int amount, int kitAmount, boolean enchanted) {
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
this.kitAmount = kitAmount;
|
||||
this.enchanted = enchanted;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getKeyItem(Kit kit, int amt) {
|
||||
public ItemStack getKeyItem(Kit kit, int amount) {
|
||||
UltimateKits plugin = UltimateKits.getInstance();
|
||||
ItemStack is = new ItemStack(Material.TRIPWIRE_HOOK, amt);
|
||||
ItemStack item = Settings.KEY_MATERIAL.getMaterial().getItem();
|
||||
item.setAmount(amount);
|
||||
|
||||
String kitName;
|
||||
if (kit != null)
|
||||
kitName = TextUtils.formatText(kit.getName(), true);
|
||||
else
|
||||
kitName = "Any";
|
||||
String kitName = kit != null ? TextUtils.formatText(kit.getName(), true)
|
||||
: plugin.getLocale().getMessage("general.type.any").getMessage();
|
||||
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("interface.key.title")
|
||||
.processPlaceholder("kit", kitName).getMessage());
|
||||
|
||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
if (enchanted)
|
||||
ItemUtils.addGlow(item);
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(ChatColor.YELLOW + name + " " + ChatColor.WHITE + "Key");
|
||||
lore.add(plugin.getLocale().getMessage("interface.key.name")
|
||||
.processPlaceholder("name", name).getMessage());
|
||||
|
||||
String desc1 = plugin.getLocale().getMessage("interface.key.description1")
|
||||
.processPlaceholder("kit", kitName).getMessage();
|
||||
|
||||
if (kitName.equals("Any"))
|
||||
if (kit == null)
|
||||
desc1 = desc1.replaceAll("\\[.*?\\]", "");
|
||||
else
|
||||
desc1 = desc1.replace("[", "").replace("]", "");
|
||||
@ -66,12 +71,15 @@ public class Key {
|
||||
.processPlaceholder("amt", this.kitAmount).getMessage());
|
||||
meta.setLore(lore);
|
||||
|
||||
is.setItemMeta(meta);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return is;
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||
nbtItem.set("key", name);
|
||||
nbtItem.set("kit", kit == null ? "ANY" : kit.getName());
|
||||
|
||||
return nbtItem.finish();
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -83,4 +91,8 @@ public class Key {
|
||||
public int getKitAmount() {
|
||||
return kitAmount;
|
||||
}
|
||||
|
||||
public boolean isEnchanted() {
|
||||
return enchanted;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
@ -84,39 +86,40 @@ public class Kit {
|
||||
private boolean hasRoom(Player player, int itemAmount) {
|
||||
int space = 0;
|
||||
|
||||
for (ItemStack content : player.getInventory().getContents()) {
|
||||
for (ItemStack content : player.getInventory().getStorageContents()) {
|
||||
if (content == null) {
|
||||
space++;
|
||||
}
|
||||
}
|
||||
|
||||
// Since roulette only gives one item, we don't need to check if the user has room for the whole kit.
|
||||
if (kitAnimation == KitAnimation.ROULETTE && space >= 1)
|
||||
return true;
|
||||
|
||||
return space >= itemAmount;
|
||||
}
|
||||
|
||||
public void processKeyUse(Player player) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
if (item.getType() != Material.TRIPWIRE_HOOK || !item.hasItemMeta()) {
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||
|
||||
if (!nbtItem.has("key") || !nbtItem.has("kit"))
|
||||
return;
|
||||
}
|
||||
Key key = plugin.getKeyManager().getKey(ChatColor.stripColor(item.getItemMeta().getLore().get(0)).replace(" Key", ""));
|
||||
|
||||
// This is some legacy support crap.
|
||||
String title = plugin.getLocale().getMessage("interface.key.title")
|
||||
.processPlaceholder("kit", name).getMessage();
|
||||
if (title.startsWith(ChatColor.COLOR_CHAR + "f"))
|
||||
title = title.substring(2);
|
||||
String keyName = nbtItem.getNBTObject("key").asString();
|
||||
String kitName = nbtItem.getNBTObject("kit").asString();
|
||||
|
||||
String titleAny = plugin.getLocale().getMessage("interface.key.title")
|
||||
.processPlaceholder("kit", "Any").getMessage();
|
||||
if (titleAny.startsWith(ChatColor.COLOR_CHAR + "f"))
|
||||
titleAny = titleAny.substring(2);
|
||||
boolean any = kitName.equals("ANY");
|
||||
Key key = plugin.getKeyManager().getKey(keyName);
|
||||
|
||||
if (!item.getItemMeta().getDisplayName().equals(title)
|
||||
&& !item.getItemMeta().getDisplayName().equals(titleAny)) {
|
||||
if (key == null && !any)
|
||||
return;
|
||||
|
||||
if (!any && !kitName.equals(name)) {
|
||||
plugin.getLocale().getMessage("event.crate.wrongkey").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (giveKit(player, key)) {
|
||||
plugin.getLocale().getMessage("event.key.success")
|
||||
.processPlaceholder("kit", name).sendPrefixedMessage(player);
|
||||
@ -217,7 +220,8 @@ public class Kit {
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String line : meta.getLore()) {
|
||||
if (TextUtils.convertFromInvisibleString(line).equals("----")) break;
|
||||
if (line.contains("Moveable")) continue;
|
||||
if (line.equals(TextUtils.formatText("&8----"))) break;
|
||||
newLore.add(line);
|
||||
}
|
||||
meta.setLore(newLore);
|
||||
@ -285,7 +289,15 @@ public class Kit {
|
||||
}
|
||||
|
||||
private boolean giveKit(Player player, int itemAmount, int kitAmount) {
|
||||
if (Settings.NO_REDEEM_WHEN_FULL.getBoolean() && !hasRoom(player, itemAmount)) {
|
||||
List<KitItem> innerContents = new ArrayList<>(getContents());
|
||||
int kitSize = innerContents.size();
|
||||
|
||||
// Amount of items from the kit to give to the player.
|
||||
if (kitAnimation == KitAnimation.ROULETTE) itemAmount = 1; //TODO how about kitAmount > 1? generateRandomItem() will only give 1 random item instead of kitAmount
|
||||
int itemGiveAmount = itemAmount > 0 ? itemAmount : kitSize;
|
||||
if (kitAmount > 0) itemGiveAmount = itemGiveAmount * kitAmount;
|
||||
|
||||
if (Settings.NO_REDEEM_WHEN_FULL.getBoolean() && !hasRoom(player, itemGiveAmount)) {
|
||||
plugin.getLocale().getMessage("event.claim.full").sendPrefixedMessage(player);
|
||||
return false;
|
||||
}
|
||||
@ -293,18 +305,10 @@ public class Kit {
|
||||
if (Settings.SOUNDS_ENABLED.getBoolean() && kitAnimation == KitAnimation.NONE)
|
||||
CompatibleSound.ENTITY_PLAYER_LEVELUP.play(player, 0.6F, 15.0F);
|
||||
|
||||
List<KitItem> innerContents = new ArrayList<>(getContents());
|
||||
int kitSize = innerContents.size();
|
||||
|
||||
// Amount of items from the kit to give to the player.
|
||||
int itemGiveAmount = itemAmount > 0 ? itemAmount : kitSize;
|
||||
if (kitAmount > 0) itemGiveAmount = itemGiveAmount * kitAmount;
|
||||
|
||||
return generateRandomItem(innerContents, itemGiveAmount, player);
|
||||
}
|
||||
|
||||
private boolean generateRandomItem(List<KitItem> innerContents, int itemGiveAmount, Player player) {
|
||||
|
||||
if (innerContents.size() != itemGiveAmount || kitAnimation != KitAnimation.NONE)
|
||||
Collections.shuffle(innerContents);
|
||||
|
||||
@ -312,8 +316,8 @@ public class Kit {
|
||||
if (itemGiveAmount == 0) break;
|
||||
double ch = item.getChance() == 0 ? 100 : item.getChance();
|
||||
double rand = Math.random() * 100;
|
||||
itemGiveAmount--;
|
||||
if (rand < ch || ch == 100) {
|
||||
itemGiveAmount--;
|
||||
|
||||
ItemStack parseStack = item.getContent().process(player);
|
||||
if (kitAnimation != KitAnimation.NONE) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.songoda.ultimatekits.kit;
|
||||
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.type.KitContent;
|
||||
@ -13,9 +15,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.*;
|
||||
|
||||
public class KitItem {
|
||||
|
||||
@ -32,26 +32,13 @@ public class KitItem {
|
||||
}
|
||||
|
||||
public KitItem(ItemStack item, String line) {
|
||||
ItemStack itemStack = item.clone();
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (itemStack.hasItemMeta() && meta.hasDisplayName() && meta.getDisplayName().contains(";")) {
|
||||
translateLine(meta.getDisplayName());
|
||||
}
|
||||
translateTags(item);
|
||||
processContent(line, null);
|
||||
}
|
||||
|
||||
public KitItem(ItemStack item) {
|
||||
ItemStack itemStack = item.clone();
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (itemStack.hasItemMeta() && meta.hasDisplayName() && meta.getDisplayName().contains(";")) {
|
||||
String translated = translateLine(meta.getDisplayName()).replace(TextUtils.convertToInvisibleString("faqe"), "");
|
||||
if (translated.equalsIgnoreCase(WordUtils.capitalize(item.getType().toString().toLowerCase().replace("_", " "))))
|
||||
meta.setDisplayName(null);
|
||||
else
|
||||
meta.setDisplayName(translated);
|
||||
itemStack.setItemMeta(meta);
|
||||
}
|
||||
processContent(null, itemStack);
|
||||
translateTags(item);
|
||||
processContent(null, item.clone());
|
||||
}
|
||||
|
||||
private void processContent(String line, ItemStack item) {
|
||||
@ -65,6 +52,18 @@ public class KitItem {
|
||||
}
|
||||
}
|
||||
|
||||
private void translateTags(ItemStack item) {
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||
if (nbtItem.has("chance"))
|
||||
chance = nbtItem.getNBTObject("chance").asDouble();
|
||||
if (nbtItem.has("display-item"))
|
||||
displayItem = Material.valueOf(nbtItem.getNBTObject("display-item").asString());
|
||||
if (nbtItem.has("display-name"))
|
||||
displayName = nbtItem.getNBTObject("display-name").asString();
|
||||
if (nbtItem.has("display-lore"))
|
||||
displayLore = nbtItem.getNBTObject("display-lore").asString();
|
||||
}
|
||||
|
||||
private String translateLine(String line) {
|
||||
String[] lineSplit = line.trim().split(";", 2);
|
||||
String[] kitOptions = lineSplit[0].replace(String.valueOf(ChatColor.COLOR_CHAR), "").split("~");
|
||||
@ -94,7 +93,19 @@ public class KitItem {
|
||||
return lineSplit[1];
|
||||
}
|
||||
|
||||
private String compileOptions() {
|
||||
private ItemStack compileOptions(ItemStack item) {
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||
if (chance != 0)
|
||||
nbtItem.set("chance", chance);
|
||||
if (displayItem != null)
|
||||
nbtItem.set("display-item", displayItem.name());
|
||||
if (displayName != null)
|
||||
nbtItem.set("display-name", displayName);
|
||||
if (displayLore != null)
|
||||
nbtItem.set("display-lore", displayLore);
|
||||
return nbtItem.finish();
|
||||
}
|
||||
private String compileOptionsText() {
|
||||
String line = "";
|
||||
if (chance != 0)
|
||||
line += "chance:" + chance;
|
||||
@ -114,7 +125,7 @@ public class KitItem {
|
||||
public String getSerialized() {
|
||||
if (chance == 0 && displayItem == null && displayName == null && displayLore == null)
|
||||
return this.content.getSerialized();
|
||||
return compileOptions() + ";" + this.content.getSerialized();
|
||||
return compileOptionsText() + ";" + this.content.getSerialized();
|
||||
}
|
||||
|
||||
public double getChance() {
|
||||
@ -155,17 +166,15 @@ public class KitItem {
|
||||
|
||||
public ItemStack getMoveableItem() {
|
||||
if (content == null) return null;
|
||||
ItemStack item = content.getItemForDisplay();
|
||||
ItemStack item = content.getItemForDisplay().clone();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (chance != 0 || displayItem != null || displayName != null || displayLore != null) {
|
||||
String capitalizedName = meta.hasDisplayName() ? meta.getDisplayName() :
|
||||
WordUtils.capitalize(item.getType().toString().toLowerCase().replace("_", " "));
|
||||
if (capitalizedName.contains(TextUtils.convertToInvisibleString(";faqe")))
|
||||
capitalizedName = meta.getDisplayName().split(TextUtils.convertToInvisibleString(";faqe"))[1];
|
||||
meta.setDisplayName(TextUtils.convertToInvisibleString(compileOptions() + ";faqe") + capitalizedName);
|
||||
}
|
||||
List<String> lore = meta.hasLore() && meta.getLore().get(0).equals(TextUtils.formatText("&8&oMoveable"))
|
||||
? new ArrayList<>() : new ArrayList<>(Collections.singletonList(TextUtils.formatText("&8&oMoveable")));
|
||||
if (meta.hasLore())
|
||||
lore.addAll(meta.getLore());
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
return compileOptions(item);
|
||||
}
|
||||
|
||||
public ItemStack getItemForDisplay() {
|
||||
@ -181,19 +190,18 @@ public class KitItem {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
|
||||
}
|
||||
if (displayLore != null) {
|
||||
meta.setLore(Arrays.asList(ChatColor.translateAlternateColorCodes('&', displayLore)));
|
||||
meta.setLore(Collections.singletonList(ChatColor.translateAlternateColorCodes('&', displayLore)));
|
||||
}
|
||||
|
||||
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Display Chance In Preview")) {
|
||||
ArrayDeque<String> lore;
|
||||
if (meta.hasLore()) {
|
||||
if (meta.hasLore())
|
||||
lore = new ArrayDeque<>(meta.getLore());
|
||||
} else {
|
||||
else
|
||||
lore = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
if (!lore.isEmpty()) lore.addFirst("");
|
||||
lore.addFirst(ChatColor.GRAY.toString() + UltimateKits.getInstance().getLocale().getMessage("general.type.chance") + ": " + ChatColor.GOLD + (chance == 0 ? 100 : chance) + "%");
|
||||
lore.addFirst(ChatColor.GRAY.toString() + UltimateKits.getInstance().getLocale().getMessage("general.type.chance").getMessage() + ": " + ChatColor.GOLD + (chance == 0 ? 100 : chance) + "%");
|
||||
meta.setLore(new ArrayList<>(lore));
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ public class Settings {
|
||||
public static final ConfigSetting CHANCE_IN_PREVIEW = new ConfigSetting(config, "Main.Display Chance In Preview", true);
|
||||
public static final ConfigSetting CURRENCY_SYMBOL = new ConfigSetting(config, "Main.Currency Symbol", "$");
|
||||
public static final ConfigSetting STARTER_KIT = new ConfigSetting(config, "Main.Starter Kit", "none");
|
||||
public static final ConfigSetting KEY_MATERIAL = new ConfigSetting(config, "Main.Key Material", "TRIPWIRE_HOOK",
|
||||
"What type of material should be used for kit keys?");
|
||||
|
||||
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "Main.Economy", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
|
||||
"Which economy plugin should be used?",
|
||||
|
@ -10,9 +10,8 @@ general:
|
||||
money: '&6Money'
|
||||
link: '&9Link'
|
||||
free: Free
|
||||
|
||||
any: Any
|
||||
# Interface Messages
|
||||
|
||||
interface:
|
||||
selector:
|
||||
kit: '&c%kit%'
|
||||
@ -51,19 +50,19 @@ interface:
|
||||
'no': '&c&lNo'
|
||||
key:
|
||||
title: '&5%kit% &fKit Key'
|
||||
description1: '&rRight-Click on [a ]&c&l%kit%&r kit'
|
||||
description2: '&rand receive its contents!'
|
||||
description3: '&rand receive some of its contents!'
|
||||
description4: '&rGives kit &c&l%amt% &rtimes.'
|
||||
name: '&e%name% &fKey'
|
||||
description1: '&fRight-Click on [a ]&c&l%kit%&f kit'
|
||||
description2: '&fand receive its contents!'
|
||||
description3: '&fand receive some of its contents!'
|
||||
description4: '&fGives kit &c&l%amt% &ftimes.'
|
||||
crate:
|
||||
title: '&5%kit% &f%crate% Crate'
|
||||
description1: '&rRight-Click to open'
|
||||
description2: '&rand receive its contents!'
|
||||
description3: '&rand receive some of its contents!'
|
||||
description4: '&rLeft-Click to preview'
|
||||
|
||||
# Administrative interfaces
|
||||
description1: '&fRight-Click to open'
|
||||
description2: '&fand receive its contents!'
|
||||
description3: '&fand receive some of its contents!'
|
||||
description4: '&fLeft-Click to preview'
|
||||
|
||||
# Administrative interfaces
|
||||
kitblock:
|
||||
title: '&8This contains &a%kit%'
|
||||
switchtype: '&5&lSwitch kit type'
|
||||
@ -164,9 +163,7 @@ interface:
|
||||
switchtokitfunctionslore: '&7Click to switch back|&7to the kit functions.'
|
||||
itemfunctionlore: '&7Display Item: &6%item%|&7Display Name: &6%name%|&7Display Lore: &6%lore%||&7Left-Click: &6To set a display item.|&7Middle-Click: &6To set a display name.|&7Right-Click: &6To set display lore.|&7Shift-Click: &6To set chance.||&7Display options only show up on display.|&7This can be useful if you want to explain|&7What an item does without putting it in the|&7permanent lore.||&6Leave function mode to move items.'
|
||||
saved: '&8Changes to &a%kit% &8saved successfully.'
|
||||
|
||||
# Command Messages
|
||||
|
||||
command:
|
||||
general:
|
||||
noperms: '&cYou do not have permission to do that!'
|
||||
@ -179,9 +176,7 @@ command:
|
||||
crate:
|
||||
given: '&9Gave &7%player% &9crate &7%crate% &9for kit &7%kit%.'
|
||||
doesntexist: '&cThis crate is not loaded.'
|
||||
|
||||
# Event Messages
|
||||
|
||||
event:
|
||||
preview:
|
||||
kit: '&9You are now previewing kit &7%kit%&9.'
|
||||
@ -208,4 +203,4 @@ event:
|
||||
cancelled: '&cPurchase Canceled.'
|
||||
key:
|
||||
given: '&9You have received a &a%kit% &9kit key.'
|
||||
success: '&9You have successfully redeemed a key for the kit &7%kit%&9.'
|
||||
success: '&9You have successfully redeemed a key for the kit &7%kit%&9.'
|
||||
|
Loading…
Reference in New Issue
Block a user