mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-10-06 17:47:36 +02:00
Will now display chance in preview when enabled.
Fixed issue with rewriting command in preview.
This commit is contained in:
parent
e66387e3b6
commit
0801043ea6
@ -58,6 +58,8 @@ public enum Lang {
|
||||
|
||||
COMMAND("Command", "&7Command"),
|
||||
|
||||
CHANCE("Chance", "Chance"),
|
||||
|
||||
MONEY("Money", "&6Money"),
|
||||
|
||||
LINK("Link", "&9Link"),
|
||||
|
@ -101,7 +101,7 @@ public class KitEditor {
|
||||
if (meta.hasLore()) itemLore = meta.getLore();
|
||||
else itemLore = new ArrayList<>();
|
||||
itemLore.add(TextComponent.convertToInvisibleString("----"));
|
||||
itemLore.add(TextComponent.formatText("&7Chance: &6" + item.getChance() + "%"));
|
||||
itemLore.add(TextComponent.formatText("&7" + Lang.CHANCE.getConfigValue() + ": &6" + item.getChance() + "%"));
|
||||
if (playerData.isInFuction()) {
|
||||
itemLore.add(TextComponent.formatText("&7Display Item: &6" + (item.getDisplayItem() == null ? "null" : item.getDisplayItem().name())));
|
||||
itemLore.add(TextComponent.formatText("&7Display Name: &6" + TextComponent.formatText(item.getDisplayName())));
|
||||
|
@ -316,17 +316,25 @@ public class Kit {
|
||||
if (num == (max - 18))
|
||||
num++;
|
||||
}
|
||||
if (is.getAmount() > 64) {
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasLore()) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
for (String str : is.getItemMeta().getLore()) {
|
||||
str = str.replace("{PLAYER}", p.getName());
|
||||
str = str.replace("<PLAYER>", p.getName());
|
||||
lore.add(str);
|
||||
}
|
||||
is.getItemMeta().setLore(lore);
|
||||
|
||||
}
|
||||
ItemMeta meta = is.hasItemMeta() ? is.getItemMeta() : Bukkit.getItemFactory().getItemMeta(is.getType());
|
||||
ArrayDeque<String> lore;
|
||||
if (meta.hasLore()) {
|
||||
lore = new ArrayDeque<>(meta.getLore());
|
||||
} else {
|
||||
lore = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String str : lore) {
|
||||
str = str.replace("{PLAYER}", p.getName()).replace("<PLAYER>", p.getName());
|
||||
newLore.add(str);
|
||||
}
|
||||
|
||||
meta.setLore(newLore);
|
||||
is.setItemMeta(meta);
|
||||
|
||||
if (is.getAmount() > 64) {
|
||||
int overflow = is.getAmount() % 64;
|
||||
int stackamt = is.getAmount() / 64;
|
||||
int num3 = 0;
|
||||
|
@ -1,17 +1,21 @@
|
||||
package com.songoda.ultimatekits.kit;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.ultimatekits.Lang;
|
||||
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.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
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;
|
||||
|
||||
public class KitItem {
|
||||
@ -170,6 +174,19 @@ public class KitItem {
|
||||
meta.setLore(Arrays.asList(TextComponent.formatText(displayLore)));
|
||||
}
|
||||
|
||||
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Display Chance In Preview")) {
|
||||
ArrayDeque<String> lore;
|
||||
if (meta.hasLore()) {
|
||||
lore = new ArrayDeque<>(meta.getLore());
|
||||
} else {
|
||||
lore = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
if (lore.size() != 0) lore.addFirst("");
|
||||
lore.addFirst(TextComponent.formatText("&7" + Lang.CHANCE.getConfigValue() + ": &6" + (chance == 0 ? 100 : chance) + "%"));
|
||||
meta.setLore(new ArrayList<>(lore));
|
||||
}
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
@ -222,6 +222,7 @@ public class SettingsManager implements Listener {
|
||||
o7("EnableSound", "Main.Sounds Enabled", true),
|
||||
o8("Sound", "Main.Sound Played While Clicking In Inventories", "ENTITY_ENDERMAN_TELEPORT"),
|
||||
o85("-", "Main.Prevent The Redeeming of a Kit When Inventory Is Full", true),
|
||||
o342("-", "Main.Display Chance In Preview", true),
|
||||
CURRENCY_SYMBOL("-", "Main.Currency Symbol", "$"),
|
||||
|
||||
o9("Exit-Icon", "Interfaces.Exit Icon", "OAK_DOOR"),
|
||||
|
Loading…
Reference in New Issue
Block a user