fix editor,config errors

This commit is contained in:
jascotty2 2019-10-04 11:36:46 -05:00
parent c8ecab352b
commit bb2cdea235
15 changed files with 139 additions and 109 deletions

View File

@ -79,21 +79,21 @@ public class CommandKey extends AbstractCommand {
List<String> tab = new ArrayList<>();
if (args.length == 2) {
if (args.length == 1) {
tab.add("all");
for (Kit kit : UltimateKits.getInstance().getKitManager().getKits())
tab.add(kit.getName());
return tab;
} else if (args.length == 3) {
} else if (args.length == 2) {
for (Key key : UltimateKits.getInstance().getKeyManager().getKeys())
tab.add(key.getName());
return tab;
} else if (args.length == 4) {
} else if (args.length == 3) {
tab.add("all");
for (Player player : Bukkit.getOnlinePlayers())
tab.add(player.getName());
return tab;
} else if (args.length == 5) return Arrays.asList("amount");
} else if (args.length == 4) return Arrays.asList("amount");
return tab;
}

View File

@ -33,7 +33,7 @@ public class CommandKit extends AbstractCommand {
return ReturnType.SUCCESS;
}
if (args.length == 0) {
new KitSelectorGui(instance, (Player) sender);
guiManager.showGUI((Player) sender, new KitSelectorGui(instance, (Player) sender));
} else if (args.length == 1) {
Player player = (Player) sender;
String kitName = args[0].toLowerCase();

View File

@ -58,14 +58,14 @@ public class BlockEditorGui extends Gui {
// decor options
setButton(1, 4, GuiUtils.createButtonItem(CompatibleMaterial.POPPY,
plugin.getLocale().getMessage("interface.kitblock.decor").getMessage(),
plugin.getLocale().getMessage("interface.kitblock.decorlore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kitblock.decorlore").getMessage().split("\\|")),
ClickType.LEFT,
event -> event.manager.showGUI(event.player, new KitDecorOptionsGui(plugin, kitBlockData, this)));
// edit
setButton(1, 6, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_PICKAXE,
plugin.getLocale().getMessage("interface.kitblock.edit").getMessage(),
plugin.getLocale().getMessage("interface.kitblock.editlore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kitblock.editlore").getMessage().split("\\|")),
ClickType.LEFT,
event -> {
new KitEditorGui(UltimateKits.getInstance(), event.player, kitBlockData.getKit(), this);
@ -74,7 +74,7 @@ public class BlockEditorGui extends Gui {
}
List<String> kitTypeLore(UltimateKits plugin) {
String[] type = plugin.getLocale().getMessage("interface.kitblock.switchtypelore").getMessage().split("|");
String[] type = plugin.getLocale().getMessage("interface.kitblock.switchtypelore").getMessage().split("\\|");
return Arrays.asList(
type[0],
(kitBlockData.getType() == KitType.PREVIEW ? ChatColor.GOLD : ChatColor.GRAY) + (type.length > 1 ? type[1] : "Preview"),

View File

@ -39,7 +39,7 @@ public class ConfirmBuyGui extends Gui {
plugin.getLocale().getMessage("interface.yesno.yes").getMessage()),
event -> {
kit.processPurchaseUse(event.player);
event.player.closeInventory();
exit();
});
// cancel button

View File

@ -76,7 +76,7 @@ public class KitDecorOptionsGui extends Gui {
plugin.getLocale().getMessage("interface.kitdecor.displayone").getMessage(),
plugin.getLocale().getMessage("interface.kitdecor.displayonelore")
.processPlaceholder("enabled", kitBlockData.isItemOverride() ? enableLore : disableLore)
.getMessage().split("|")),
.getMessage().split("\\|")),
event -> {
kitBlockData.setItemOverride(!kitBlockData.isItemOverride());
updateItemLore(event.slot, kitBlockData.isItemOverride() ? enableLore : disableLore);

View File

@ -3,8 +3,10 @@ package com.songoda.ultimatekits.gui;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.gui.AnvilGui;
import com.songoda.core.gui.DoubleGui;
import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiUtils;
import com.songoda.core.input.ChatPrompt;
import com.songoda.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatekits.UltimateKits;
@ -25,7 +27,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class KitEditorGui extends Gui {
public class KitEditorGui extends DoubleGui {
private UltimateKits plugin;
private Kit kit;
@ -49,14 +51,10 @@ public class KitEditorGui extends Gui {
.getMessage());
saveItemsInstance();
getInvItems();
setInvItems();
setOnClose((event) -> {
this.saveKit(player, inventory, false);
if (!isInInventory && this.inventoryItems.length != 0) {
player.getInventory().setContents(this.inventoryItems);
player.updateInventory();
}
CompatibleSound.ENTITY_VILLAGER_YES.play(player);
});
@ -86,10 +84,11 @@ public class KitEditorGui extends Gui {
// info icon
setItem(0, 4, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
plugin.getLocale().newMessage("&5&l" + kit.getName()).getMessage(),
plugin.getLocale().newMessage("&&fPermissions:").getMessage(),
plugin.getLocale().newMessage("&&7ultimatekits.kit." + kit.getName().toLowerCase()).getMessage()
));
plugin.getLocale().getMessage("interface.kiteditor.info")
.processPlaceholder("kit", kit.getName())
.processPlaceholder("perm", "ultimatekits.kit." + kit.getName().toLowerCase())
.getMessage().split("\\|"))
);
paint();
}
@ -109,17 +108,17 @@ public class KitEditorGui extends Gui {
int num3 = 0;
while (num3 != stackamt) {
is.setAmount(64);
inventory.setItem(num, is);
setItem(num, is);
num++;
num3++;
}
if (overflow != 0) {
is.setAmount(overflow);
inventory.setItem(num, is);
setItem(num, is);
num++;
}
} else {
inventory.setItem(num, is);
setItem(num, is);
num++;
}
}
@ -127,19 +126,22 @@ public class KitEditorGui extends Gui {
}
private void updateInvButton() {
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
plugin.getLocale().getMessage("interface.kiteditor.itemediting").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.itemeditinglore").getMessage());
ItemStack item;
if (!isInFuction) {
setUnlockedRange(1, 1, 1, 7);
setUnlockedRange(2, 0, 3, 8);
setUnlockedRange(4, 1, 4, 7);
item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
plugin.getLocale().getMessage("interface.kiteditor.itemediting").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.itemeditinglore").getMessage().split("\\|"));
} else {
unlockedCells.clear();
item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
plugin.getLocale().getMessage("interface.kiteditor.itemmoving").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.itemmovinglore").getMessage());
plugin.getLocale().getMessage("interface.kiteditor.itemmovinglore").getMessage().split("\\|"));
}
setButton(48, item,
@ -149,58 +151,70 @@ public class KitEditorGui extends Gui {
paint();
});
ItemStack item2 = GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME,
plugin.getLocale().getMessage("interface.kiteditor.switchtokitfunctions").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.switchtokitfunctionslore").getMessage().split("|"));
setAcceptsItems(!isInInventory);
ItemStack item2;
if (isInInventory) {
item2 = GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME,
plugin.getLocale().getMessage("interface.kiteditor.switchtokitfunctions").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.switchtokitfunctionslore").getMessage().split("\\|"));
} else {
item2 = GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME,
plugin.getLocale().getMessage("interface.kiteditor.switchtoinventory").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.switchtoinventorylore").getMessage().split("\\|"));
}
setButton(50, item2,
(event) -> {
event -> {
if (!isInInventory) {
player.getInventory().setContents(inventoryItems);
isInInventory = true;
player.updateInventory();
restoreItemsInstance();
} else {
saveItemsInstance();
getInvItems();
setInvItems();
}
updateInvButton();
});
}
private void saveItemsInstance() {
setPlayerUnlockedRange(0, 0, 3, 8, false);
inventoryItems = player.getInventory().getContents().clone();
player.getInventory().clear();
isInInventory = false;
}
private void getInvItems() {
isInInventory = false;
private void restoreItemsInstance() {
setPlayerUnlockedRange(0, 0, 3, 8);
player.getInventory().setContents(inventoryItems);
player.updateInventory();
isInInventory = true;
}
setButton(9, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE_TORCH,
private void setInvItems() {
setPlayerButton(9, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE_TORCH,
plugin.getLocale().getMessage("interface.kiteditor.generaloptions").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.generaloptionslore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kiteditor.generaloptionslore").getMessage().split("\\|")),
(event) -> guiManager.showGUI(player, new KitGeneralOptionsGui(plugin, player, kit, this)));
setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.EMERALD,
setPlayerButton(10, GuiUtils.createButtonItem(CompatibleMaterial.EMERALD,
plugin.getLocale().getMessage("interface.kiteditor.sellingoptions").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.sellingoptionslore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kiteditor.sellingoptionslore").getMessage().split("\\|")),
(event) -> guiManager.showGUI(player, new KitSellingOptionsGui(plugin, player, kit, this)));
setButton(12, GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME,
setPlayerButton(12, GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME,
plugin.getLocale().getMessage("interface.kiteditor.guioptions").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.guioptionslore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kiteditor.guioptionslore").getMessage().split("\\|")),
(event) -> guiManager.showGUI(player, new KitGuiOptionsGui(plugin, player, kit, parent)));
setButton(13, GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
setPlayerButton(13, GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
plugin.getLocale().getMessage("interface.kiteditor.addcommand").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.addcommandlore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kiteditor.addcommandlore").getMessage().split("\\|")),
(event) -> {
// TODO: this should be a chat listener, not anvil
AnvilGui gui = new AnvilGui(player, this);
gui.setTitle(plugin.getLocale().getMessage("interface.kiteditor.addcommandpromp").getMessage());
gui.setAction(aevent -> {
String msg = gui.getInputText();
event.gui.exit();
ChatPrompt.showPrompt(event.manager.getPlugin(), event.player, "Enter a command for this kit:", response -> {
String msg = response.getMessage().trim();
ItemStack parseStack = new ItemStack(Material.PAPER, 1);
ItemMeta meta = parseStack.getItemMeta();
@ -221,14 +235,13 @@ public class KitEditorGui extends Gui {
.sendPrefixedMessage(player);
this.inventory.addItem(parseStack);
});
guiManager.showGUI(event.player, gui);
}).setOnClose(() -> {event.manager.showGUI(event.player, this); })
.setOnCancel(() -> {event.player.sendMessage(ChatColor.RED + "Edit canceled"); event.manager.showGUI(event.player, this);});
});
setButton(14, GuiUtils.createButtonItem(CompatibleMaterial.SUNFLOWER,
setPlayerButton(14, GuiUtils.createButtonItem(CompatibleMaterial.SUNFLOWER,
plugin.getLocale().getMessage("interface.kiteditor.addeconomy").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.addeconomylore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kiteditor.addeconomylore").getMessage().split("\\|")),
(event) -> {
AnvilGui gui = new AnvilGui(player, this);
gui.setTitle(plugin.getLocale().getMessage("interface.kiteditor.addeconomyprompt").getMessage());
@ -258,16 +271,18 @@ public class KitEditorGui extends Gui {
guiManager.showGUI(event.player, gui);
});
setButton(17, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
setPlayerButton(17, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
plugin.getLocale().getMessage("interface.kiteditor.animation").getMessage(),
plugin.getLocale().getMessage("interface.kiteditor.animationlore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kiteditor.animationlore")
.processPlaceholder("animation", kit.getKitAnimation().name())
.getMessage().split("\\|")),
(event) -> {
if (kit.getKitAnimation() == KitAnimation.NONE) {
kit.setKitAnimation(KitAnimation.ROULETTE);
} else {
kit.setKitAnimation(KitAnimation.NONE);
}
getInvItems();
setInvItems();
});
}
@ -368,7 +383,7 @@ public class KitEditorGui extends Gui {
.processPlaceholder("item", item.getDisplayItem() == null ? "" : item.getDisplayItem().name())
.processPlaceholder("name", item.getDisplayName())
.processPlaceholder("lore", item.getDisplayLore())
.getMessage().split("|")));
.getMessage().split("\\|")));
}
meta.setLore(itemLore);
is.setItemMeta(meta);

View File

@ -40,7 +40,7 @@ public class KitGeneralOptionsGui extends Gui {
setButton(1, 2, GuiUtils.createButtonItem(CompatibleMaterial.CLOCK,
plugin.getLocale().getMessage("interface.kitoptions.delay").getMessage(),
plugin.getLocale().getMessage("interface.kitoptions.delaylore")
.processPlaceholder("delay", kit.getDelay()).getMessage().split("|")),
.processPlaceholder("delay", kit.getDelay()).getMessage().split("\\|")),
event -> {
AnvilGui gui = new AnvilGui(event.player, this);
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.delayprompt").getMessage());
@ -51,7 +51,7 @@ public class KitGeneralOptionsGui extends Gui {
try {
kit.setDelay(Integer.parseInt(num));
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitoptions.delaylore")
.processPlaceholder("delay", kit.getDelay()).getMessage().split("|"));
.processPlaceholder("delay", kit.getDelay()).getMessage().split("\\|"));
aevent.player.closeInventory();
} catch (NumberFormatException e) {
}
@ -64,7 +64,7 @@ public class KitGeneralOptionsGui extends Gui {
// delete
setButton(1, 6, GuiUtils.createButtonItem(CompatibleMaterial.TNT,
plugin.getLocale().getMessage("interface.kitoptions.destroy").getMessage(),
plugin.getLocale().getMessage("interface.kitoptions.destroylore").getMessage().split("|")),
plugin.getLocale().getMessage("interface.kitoptions.destroylore").getMessage().split("\\|")),
event -> {
AnvilGui gui = new AnvilGui(event.player, this);
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.destroyprompt").processPlaceholder("kit", kit.getName()).getMessage());

View File

@ -46,7 +46,7 @@ public class KitGuiOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.holoon").processPlaceholder("title", kit.getTitle()).getMessage()
: plugin.getLocale().getMessage("interface.kitguioptions.holooff").getMessage()
).getMessage().split("|")),
).getMessage().split("\\|")),
ClickType.LEFT,
event -> {
AnvilGui gui = new AnvilGui(event.player, this);
@ -65,7 +65,7 @@ public class KitGuiOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.holoon").processPlaceholder("title", kit.getTitle()).getMessage()
: plugin.getLocale().getMessage("interface.kitguioptions.holooff").getMessage()
).getMessage().split("|"));
).getMessage().split("\\|"));
aevent.player.closeInventory();
});
@ -79,7 +79,7 @@ public class KitGuiOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.holoon").processPlaceholder("title", kit.getTitle()).getMessage()
: plugin.getLocale().getMessage("interface.kitguioptions.holooff").getMessage()
).getMessage().split("|"));
).getMessage().split("\\|"));
});
setButton(1, 4, GuiUtils.createButtonItem(kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.BEACON,
@ -88,7 +88,7 @@ public class KitGuiOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.itemon").processPlaceholder("item", kit.getDisplayItem().toString()).getMessage()
: plugin.getLocale().getMessage("interface.kitguioptions.itemoff").getMessage()
).getMessage().split("|")),
).getMessage().split("\\|")),
ClickType.LEFT,
event -> {
ItemStack is = player.getItemInHand();
@ -103,7 +103,7 @@ public class KitGuiOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.itemon").processPlaceholder("item", kit.getDisplayItem().toString()).getMessage()
: plugin.getLocale().getMessage("interface.kitguioptions.itemoff").getMessage()
).getMessage().split("|"));
).getMessage().split("\\|"));
}
});
setAction(1, 4, ClickType.RIGHT, event -> {
@ -115,7 +115,7 @@ public class KitGuiOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.itemon").processPlaceholder("item", kit.getDisplayItem().toString()).getMessage()
: plugin.getLocale().getMessage("interface.kitguioptions.itemoff").getMessage()
).getMessage().split("|"));
).getMessage().split("\\|"));
});
setButton(1, 4, GuiUtils.createButtonItem(kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.BEACON,
@ -123,7 +123,7 @@ public class KitGuiOptionsGui extends Gui {
plugin.getLocale().getMessage("interface.kitguioptions.hidelore")
.processPlaceholder("onoff", plugin.getLocale().getMessage(
kit.isHidden() ? "interface.kitguioptions.hideon" : "interface.kitguioptions.hideoff").getMessage()
).getMessage().split("|")),
).getMessage().split("\\|")),
ClickType.LEFT,
event -> {
kit.setHidden(!kit.isHidden());
@ -131,7 +131,7 @@ public class KitGuiOptionsGui extends Gui {
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitguioptions.hidelore")
.processPlaceholder("onoff", plugin.getLocale().getMessage(
kit.isHidden() ? "interface.kitguioptions.hideon" : "interface.kitguioptions.hideoff").getMessage()
).getMessage().split("|"));
).getMessage().split("\\|"));
});
}
}

View File

@ -16,6 +16,7 @@ import java.util.Random;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@ -43,21 +44,21 @@ public class KitSelectorGui extends Gui {
int nrows = (int) Math.ceil(kitList.size() / (double) showPerRow);
setRows(glassless ? nrows : nrows + 2);
showPerPage = showPerRow * (glassless ? (nrows == 6 ? 6 : 5) : 4);
pages = kitList.size() / showPerPage;
page = 1;
setPages(kitList.size() / showPerPage);
setItem(0, 4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK,
plugin.getLocale().getMessage("interface.selector.details")
.processPlaceholder("player", player.getName()).getMessage().split("\\|")));
this.setNextPage(rows - 1, 5, GuiUtils.createButtonItem(ItemUtils.getCustomHead("1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b"),
plugin.getLocale().getMessage("interface.button.next").getMessage()));
if (pages > 1) {
this.setNextPage(rows - 1, 5, GuiUtils.createButtonItem(ItemUtils.getCustomHead("1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b"),
plugin.getLocale().getMessage("interface.button.next").getMessage()));
this.setPrevPage(rows - 1, 3, GuiUtils.createButtonItem(ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
plugin.getLocale().getMessage("interface.button.last").getMessage()));
this.setPrevPage(rows - 1, 3, GuiUtils.createButtonItem(ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
plugin.getLocale().getMessage("interface.button.last").getMessage()));
this.setOnPage(pager -> showPage());
showPage();
this.setOnPage(pager -> showPage());
}
if (!glassless) {
setButton(rows - 1, 4, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
@ -87,6 +88,8 @@ public class KitSelectorGui extends Gui {
GuiUtils.mirrorFill(this, 0, 3, false, true, glass1);
}
}
showPage();
}
private void loadKits() {
@ -99,11 +102,11 @@ public class KitSelectorGui extends Gui {
static final Random rand = new Random();
private void animateGlass() {
for(int col = 1; col < 7; ++col) {
for(int col = 1; col < 8; ++col) {
ItemStack it;
if((it = getItem(0, col)) == null || it.getType().name().contains("PANE"))
if((it = getItem(0, col)) == null || it.getType() == Material.AIR || it.getType().name().contains("PANE"))
setItem(0, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
if((it = getItem(rows - 1, col)) == null || it.getType().name().contains("PANE"))
if((it = getItem(rows - 1, col)) == null || it.getType() == Material.AIR || it.getType().name().contains("PANE"))
setItem(rows - 1, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
}
for(int row = 1; row + 1 < rows; ++row) {
@ -114,8 +117,13 @@ public class KitSelectorGui extends Gui {
private void showPage() {
int index = (page - 1) * showPerPage;
for (int row = glassless ? 0 : 1; row < (!glassless || pages != 1 ? rows - 2 : rows - 1) && index < kitList.size(); ++row) {
for (int col = glassless ? 0 : 1; col < (glassless ? 9 : 8) && index < kitList.size(); ++col) {
for (int row = glassless ? 0 : 1; row < (!glassless || pages != 1 ? rows - 1 : rows); ++row) {
for (int col = glassless ? 0 : 1; col < (glassless ? 9 : 8); ++col) {
if(index >= kitList.size()) {
setItem(row, col, null);
clearActions(row, col);
continue;
}
final String kitItem = kitList.get(index++);
final Kit kit = plugin.getKitManager().getKit(kitItem);

View File

@ -46,7 +46,7 @@ public class KitSellingOptionsGui extends Gui {
plugin.getLocale().getMessage("interface.kitsell.noselllore")
.processPlaceholder("onoff", plugin.getLocale().getMessage(
kit.getPrice() != 0 || kit.getLink() != null ? "interface.kitsell.nosellon" : "interface.kitsell.noselloff").getMessage()
).getMessage().split("|")),
).getMessage().split("\\|")),
event -> {
kit.setPrice(0);
kit.setLink(null);
@ -63,7 +63,7 @@ public class KitSellingOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitsell.linkon").processPlaceholder("kit", kit.getLink()).getMessage()
: plugin.getLocale().getMessage("interface.kitsell.linkoff").getMessage()
).getMessage().split("|")),
).getMessage().split("\\|")),
event -> {
AnvilGui gui = new AnvilGui(event.player, this);
gui.setTitle(plugin.getLocale().getMessage("interface.kitsell.linkprompt").getMessage());
@ -80,7 +80,7 @@ public class KitSellingOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitsell.linkon").processPlaceholder("kit", kit.getLink()).getMessage()
: plugin.getLocale().getMessage("interface.kitsell.linkoff").getMessage()
).getMessage().split("|"));
).getMessage().split("\\|"));
aevent.player.closeInventory();
});
@ -94,7 +94,7 @@ public class KitSellingOptionsGui extends Gui {
.processPlaceholder("onoff",
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitsell.priceon").processPlaceholder("kit", kit.getLink()).getMessage()
: plugin.getLocale().getMessage("interface.kitsell.priceoff").getMessage()
).getMessage().split("|")),
).getMessage().split("\\|")),
event -> {
if (!EconomyManager.isEnabled()) {
plugin.getLocale().getMessage("interface.kitsell.pricenoeco").sendPrefixedMessage(event.player);

View File

@ -110,7 +110,7 @@ public class PreviewKitGui extends Gui {
int startRow = useGlassBorder ? 1 : 0;
int endRow = useGlassBorder ? rows - 2 : rows - 1;
int startCol = useGlassBorder ? 1 : 0;
int endCol = useGlassBorder ? 8 : 7;
int endCol = useGlassBorder ? 7 : 8;
for (int row = startRow; row <= endRow; ++row) {
for (int col = startCol; col <= endCol; ++col) {
ItemStack item;
@ -170,7 +170,7 @@ public class PreviewKitGui extends Gui {
List<String> getBuyLore() {
ArrayList<String> lore = new ArrayList<>();
if (kit.hasPermission(player) && plugin.getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
if (kit.hasPermission(player) && Settings.KITS_FREE_WITH_PERMS.getBoolean()) {
lore.add(plugin.getLocale().getMessage("interface.button.clickeco")
.processPlaceholder("price", "0").getMessage());
if (player.isOp()) {

View File

@ -3,6 +3,7 @@ package com.songoda.ultimatekits.handlers;
import com.songoda.core.compatibility.CompatibleParticleHandler;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.settings.Settings;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -20,12 +21,11 @@ public class ParticleHandler {
public ParticleHandler(UltimateKits plugin) {
this.plugin = plugin;
checkDefaults();
}
public void start() {
amt = plugin.getConfig().getInt("data.particlesettings.ammount") / 2;
typeName = plugin.getConfig().getString("data.particlesettings.type");
amt = Settings.PARTICLE_AMOUNT.getInt() / 2;
typeName = Settings.PARTICLE_TYPE.getString();
type = CompatibleParticleHandler.ParticleType.getParticle(typeName);
if (type == null) {
type = CompatibleParticleHandler.ParticleType.SPELL_WITCH;
@ -45,14 +45,4 @@ public class ParticleHandler {
}
}
private void checkDefaults() {
if (plugin.getConfig().getInt("data.particlesettings.ammount") == 0) {
plugin.getConfig().set("data.particlesettings.ammount", 25);
plugin.saveConfig();
}
if (plugin.getConfig().getString("data.particlesettings.type") != null) return;
plugin.getConfig().set("data.particlesettings.type", "SPELL_WITCH");
plugin.saveConfig();
}
}

View File

@ -169,10 +169,11 @@ public class Kit {
EconomyManager.withdrawBalance(player, price);
if (delay != 0)
updateDelay(player); //updates delay on buy
plugin.getLocale().getMessage("event.claim.purchasesuccess")
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
}
plugin.getLocale().getMessage("event.claim.purchasesuccess")
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
}
public void processGenericUse(Player player, boolean forced) {
@ -299,7 +300,7 @@ public class Kit {
if (amtToGive == 0) break;
int ch = canChoose++ == forceSelect || item.getChance() == 0 ? 100 : item.getChance();
double rand = Math.random() * 100;
if (rand - ch < 0 || ch == 100) {
if (rand < ch || ch == 100) {
if (item.getContent() instanceof KitContentEconomy) {
try {

View File

@ -11,7 +11,7 @@ import java.util.stream.Collectors;
public class Settings {
static final Config config = UltimateKits.getInstance().getConfig().getCoreConfig();
static final Config config = UltimateKits.getInstance().getCoreConfig();
public static final ConfigSetting ONLY_SHOW_KITS_WITH_PERMS = new ConfigSetting(config, "Main.Only Show Players Kits They Have Permission To Use", false);
public static final ConfigSetting KITS_FREE_WITH_PERMS = new ConfigSetting(config, "Main.Allow Players To Receive Kits For Free If They Have Permission", true);
@ -48,11 +48,21 @@ public class Settings {
public static final ConfigSetting MYSQL_PASSWORD = new ConfigSetting(config, "MySQL.Password", "pass");
public static final ConfigSetting MYSQL_USE_SSL = new ConfigSetting(config, "MySQL.Use SSL", false);
public static final ConfigSetting PARTICLE_AMOUNT = new ConfigSetting(config, "data.particlesettings.amount", 25);
public static final ConfigSetting PARTICLE_TYPE = new ConfigSetting(config, "data.particlesettings.type", "SPELL_WITCH");
/**
* In order to set dynamic economy comment correctly, this needs to be
* called after EconomyManager load
*/
public static void setupConfig() {
config
.setDefaultComment("Main", "General settings and options.")
.setDefaultComment("Interfaces",
"These settings allow you to alter the way interfaces look.",
"They are used in GUI's to make patterns, change them up then open up a",
"# GUI to see how it works.")
.setDefaultComment("System", "System related settings.");
config.load();
config.setAutoremove(true).setAutosave(true);
@ -77,6 +87,11 @@ public class Settings {
config.set("Main.Economy", "PlayerPoints");
}
// spelling correction
if (config.contains("data.particlesettings.ammount")) {
config.set("data.particlesettings.amount", config.getInt("data.particlesettings.ammount"));
}
config.saveChanges();
}
}

View File

@ -11,7 +11,7 @@ general.type.free = "Free"
interface.selector.kit = "&c%kit%"
interface.selector.title = "&8Server kits"
interface.selector.details = "&7Hello &e%player%&7!|&7Listed below are our servers kit.||&7Click on the &eicon &7representing the &ekit |&7inorder to &epreview, claim or buy &7it."
interface.selector.details = "&7Hello &e%player%&7!|&7Listed below are our server's kits.||&7Click on the &eicon &7representing the &ekit |&7inorder to &epreview, claim or buy &7it."
interface.selector.aboutkitprice = "&7This kit costs &a$%price%&7."
interface.selector.aboutkit = "&7Can't open a kit?|&7Rank up to gain access!"
interface.selector.leftpreview = "&6&lLEFT CLICK &7to preview kit."
@ -106,6 +106,7 @@ interface.kitoptions.destroyprompt = "Enter \"%kit%\""
interface.kitoptions.destroyok = "&cKit destroyed successfully."
interface.kitoptions.destroycancel = "&cKit was not Destroyed."
interface.kiteditor.title = "&8You are editing kit: &9%name&8."
interface.kiteditor.info = "&5&l%kit%|&fPermissions:|&7%perm%"
interface.kiteditor.generaloptions = "&6General Options"
interface.kiteditor.generaloptionslore = "&7Click to edit adjust|&7general options."
interface.kiteditor.sellingoptions = "&9Selling Options"
@ -114,7 +115,7 @@ interface.kiteditor.guioptions = "&5GUI Options"
interface.kiteditor.guioptionslore = "&7Click to edit GUI options|&7for this kit."
interface.kiteditor.addcommand = "&fAdd Command"
interface.kiteditor.addcommandlore = "&7Click to add a command|&7to this kit."
interface.kiteditor.addcommandpromp = "Enter Command (No /)"
interface.kiteditor.addcommandprompt = "Enter Command (No /)"
interface.kiteditor.addcommandok = "&8Command &5%command%&8 has been added to your kit."
interface.kiteditor.addeconomy = "&6Add Economy"
interface.kiteditor.addeconomylore = "&7Click to add money|&7to this kit."