mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-26 12:15:13 +01:00
Merge branch 'development'
This commit is contained in:
commit
980827a2b5
87
pom.xml
87
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateKits</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.4.14</version>
|
||||
<version>2.5</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateKits-${project.version}</finalName>
|
||||
@ -106,91 +106,6 @@
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org</groupId>
|
||||
<artifactId>kingdoms</artifactId>
|
||||
<version>13.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ryanhamshire</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>7.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com</groupId>
|
||||
<artifactId>plotsquared</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.palmergames.bukkit</groupId>
|
||||
<artifactId>towny</artifactId>
|
||||
<version>0.93.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wasteofplastic</groupId>
|
||||
<artifactId>askyblock</artifactId>
|
||||
<version>3.0.6.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.talabrek</groupId>
|
||||
<artifactId>ultimateskyblock</artifactId>
|
||||
<version>2.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.markeh</groupId>
|
||||
<artifactId>factionsframework</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12</groupId>
|
||||
<artifactId>RedProtect</artifactId>
|
||||
<version>7.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50</groupId>
|
||||
<artifactId>mcmmo</artifactId>
|
||||
<version>1.5.09</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gamingmesh</groupId>
|
||||
<artifactId>jobs</artifactId>
|
||||
<version>4.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.botsko</groupId>
|
||||
<artifactId>prism</artifactId>
|
||||
<version>2.0.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.diddiz</groupId>
|
||||
<artifactId>logblock</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net</groupId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<version>2.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.antiperson</groupId>
|
||||
<artifactId>stackmob</artifactId>
|
||||
<version>2.2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sothatsit</groupId>
|
||||
<artifactId>blockstore</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
|
@ -13,6 +13,8 @@ import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.category.Category;
|
||||
import com.songoda.ultimatekits.category.CategoryManager;
|
||||
import com.songoda.ultimatekits.commands.*;
|
||||
import com.songoda.ultimatekits.conversion.Convert;
|
||||
import com.songoda.ultimatekits.database.DataManager;
|
||||
@ -23,11 +25,7 @@ import com.songoda.ultimatekits.handlers.ParticleHandler;
|
||||
import com.songoda.ultimatekits.key.Key;
|
||||
import com.songoda.ultimatekits.key.KeyManager;
|
||||
import com.songoda.ultimatekits.kit.*;
|
||||
import com.songoda.ultimatekits.listeners.BlockListeners;
|
||||
import com.songoda.ultimatekits.listeners.ChatListeners;
|
||||
import com.songoda.ultimatekits.listeners.EntityListeners;
|
||||
import com.songoda.ultimatekits.listeners.InteractListeners;
|
||||
import com.songoda.ultimatekits.listeners.PlayerListeners;
|
||||
import com.songoda.ultimatekits.listeners.*;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.ItemSerializer;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
@ -42,9 +40,11 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UltimateKits extends SongodaPlugin {
|
||||
|
||||
private static UltimateKits INSTANCE;
|
||||
|
||||
private final Config kitConfig = new Config(this, "kit.yml");
|
||||
private final Config categoryConfig = new Config(this, "category.yml");
|
||||
private final Config dataFile = new Config(this, "data.yml");
|
||||
private final Config keyFile = new Config(this, "keys.yml");
|
||||
|
||||
@ -55,6 +55,7 @@ public class UltimateKits extends SongodaPlugin {
|
||||
private KitManager kitManager;
|
||||
private CommandManager commandManager;
|
||||
private KeyManager keyManager;
|
||||
private CategoryManager categoryManager;
|
||||
|
||||
private ItemSerializer itemSerializer;
|
||||
|
||||
@ -102,10 +103,13 @@ public class UltimateKits extends SongodaPlugin {
|
||||
|
||||
this.kitManager = new KitManager();
|
||||
this.keyManager = new KeyManager();
|
||||
this.categoryManager = new CategoryManager(this);
|
||||
|
||||
kitConfig.load();
|
||||
Convert.runKitConversions();
|
||||
|
||||
categoryConfig.load();
|
||||
|
||||
// load kits
|
||||
dataFile.load();
|
||||
keyFile.load();
|
||||
@ -121,6 +125,7 @@ public class UltimateKits extends SongodaPlugin {
|
||||
.addSubCommand(new CommandReload())
|
||||
.addSubCommand(new CommandSettings(guiManager))
|
||||
.addSubCommand(new CommandCreatekit(guiManager))
|
||||
.addSubCommand(new CommandCategories(guiManager))
|
||||
.addSubCommand(new CommandEdit(guiManager))
|
||||
.addSubCommand(new CommandKey())
|
||||
.addSubCommand(new CommandSet())
|
||||
@ -181,7 +186,7 @@ public class UltimateKits extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return Arrays.asList(kitConfig, keyFile);
|
||||
return Arrays.asList(kitConfig, keyFile, categoryConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,35 +195,54 @@ public class UltimateKits extends SongodaPlugin {
|
||||
|
||||
this.dataManager.bulkUpdateBlockData(this.getKitManager().getKitLocations());
|
||||
kitConfig.load();
|
||||
categoryConfig.load();
|
||||
loadKits();
|
||||
}
|
||||
|
||||
void loadKits() {
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
|
||||
//Empty categories from manager.
|
||||
categoryManager.clearCategories();
|
||||
|
||||
/*
|
||||
* Register categories into CategoryManager from Configuration.
|
||||
*/
|
||||
if (categoryConfig.getConfigurationSection("Categories") != null)
|
||||
for (String key : categoryConfig.getConfigurationSection("Categories").getKeys(false)) {
|
||||
ConfigurationSection section = categoryConfig.getConfigurationSection("Categories." + key);
|
||||
if (section == null) continue;
|
||||
|
||||
Category category = categoryManager.addCategory(key, section.getString("name"));
|
||||
if (section.contains("material"))
|
||||
category.setMaterial(CompatibleMaterial.getMaterial(section.getString("material")).getMaterial());
|
||||
}
|
||||
|
||||
//Empty kits from manager.
|
||||
kitManager.clearKits();
|
||||
|
||||
/*
|
||||
* Register kit into KitManager from Configuration.
|
||||
* Register kits into KitManager from Configuration.
|
||||
*/
|
||||
for (String kitName : kitConfig.getConfigurationSection("Kits").getKeys(false)) {
|
||||
ConfigurationSection section = kitConfig.getConfigurationSection("Kits." + kitName);
|
||||
if (section == null) continue;
|
||||
if (kitConfig.getConfigurationSection("Kits") != null)
|
||||
for (String kitName : kitConfig.getConfigurationSection("Kits").getKeys(false)) {
|
||||
ConfigurationSection section = kitConfig.getConfigurationSection("Kits." + kitName);
|
||||
if (section == null) continue;
|
||||
|
||||
kitManager.addKit(new Kit(kitName)
|
||||
.setTitle(section.getString("title"))
|
||||
.setDelay(section.getLong("delay"))
|
||||
.setLink(section.getString("link"))
|
||||
.setDisplayItem(section.contains("displayItem")
|
||||
? CompatibleMaterial.getMaterial(section.getString("displayItem"), CompatibleMaterial.DIAMOND_HELMET)
|
||||
: null)
|
||||
.setHidden(section.getBoolean("hidden"))
|
||||
.setPrice(section.getDouble("price"))
|
||||
.setContents(section.getStringList("items").stream().map(KitItem::new).collect(Collectors.toList()))
|
||||
.setKitAnimation(KitAnimation.valueOf(section.getString("animation", KitAnimation.NONE.name())))
|
||||
);
|
||||
}
|
||||
kitManager.addKit(new Kit(kitName)
|
||||
.setTitle(section.getString("title"))
|
||||
.setDelay(section.getLong("delay"))
|
||||
.setLink(section.getString("link"))
|
||||
.setDisplayItem(section.contains("displayItem")
|
||||
? CompatibleMaterial.getMaterial(section.getString("displayItem"), CompatibleMaterial.DIAMOND_HELMET)
|
||||
: null)
|
||||
.setCategory(categoryManager.getCategory(section.getString("category")))
|
||||
.setHidden(section.getBoolean("hidden"))
|
||||
.setPrice(section.getDouble("price"))
|
||||
.setContents(section.getStringList("items").stream().map(KitItem::new).collect(Collectors.toList()))
|
||||
.setKitAnimation(KitAnimation.valueOf(section.getString("animation", KitAnimation.NONE.name())))
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register legacy kit locations into KitManager from Configuration.
|
||||
@ -276,7 +300,8 @@ public class UltimateKits extends SongodaPlugin {
|
||||
|
||||
public void removeHologram(KitBlockData data) {
|
||||
if (HologramManager.isEnabled()) {
|
||||
Location location = getKitLocation(data, Settings.HOLOGRAM_LAYOUT.getStringList().size());
|
||||
List<String> lines = formatHologram(data);
|
||||
Location location = getKitLocation(data, lines.size());
|
||||
HologramManager.removeHologram(location);
|
||||
}
|
||||
}
|
||||
@ -344,7 +369,7 @@ public class UltimateKits extends SongodaPlugin {
|
||||
case "{TITLE}":
|
||||
String title = kit.getTitle();
|
||||
if (title == null) {
|
||||
lines.add(ChatColor.DARK_PURPLE + TextUtils.formatText(kit.getName(), true));
|
||||
lines.add(ChatColor.DARK_PURPLE + TextUtils.formatText(kit.getKey(), true));
|
||||
} else {
|
||||
lines.add(ChatColor.DARK_PURPLE + TextUtils.formatText(title));
|
||||
}
|
||||
@ -395,35 +420,54 @@ public class UltimateKits extends SongodaPlugin {
|
||||
// Hot fix for kit file resets.
|
||||
if (kitConfig.contains("Kits"))
|
||||
for (String kitName : kitConfig.getConfigurationSection("Kits").getKeys(false)) {
|
||||
if (kitManager.getKits().stream().noneMatch(kit -> kit.getName().equals(kitName)))
|
||||
if (kitManager.getKits().stream().noneMatch(kit -> kit.getKey().equals(kitName)))
|
||||
kitConfig.set("Kits." + kitName, null);
|
||||
}
|
||||
|
||||
// Hot fix for category file resets.
|
||||
if (categoryConfig.contains("Categories"))
|
||||
for (String key : categoryConfig.getConfigurationSection("Categories").getKeys(false)) {
|
||||
if (categoryManager.getCategories().stream().noneMatch(category -> category.getKey().equals(key)))
|
||||
categoryConfig.set("Categories." + key, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save kit from KitManager to Configuration.
|
||||
* Save kits from KitManager to Configuration.
|
||||
*/
|
||||
for (Kit kit : kitManager.getKits()) {
|
||||
kitConfig.set("Kits." + kit.getName() + ".delay", kit.getDelay());
|
||||
kitConfig.set("Kits." + kit.getName() + ".title", kit.getTitle());
|
||||
kitConfig.set("Kits." + kit.getName() + ".link", kit.getLink());
|
||||
kitConfig.set("Kits." + kit.getName() + ".price", kit.getPrice());
|
||||
kitConfig.set("Kits." + kit.getName() + ".hidden", kit.isHidden());
|
||||
kitConfig.set("Kits." + kit.getName() + ".animation", kit.getKitAnimation().name());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".delay", kit.getDelay());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".title", kit.getTitle());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".link", kit.getLink());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".price", kit.getPrice());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".hidden", kit.isHidden());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".animation", kit.getKitAnimation().name());
|
||||
if (kit.getCategory() != null)
|
||||
kitConfig.set("Kits." + kit.getKey() + ".category", kit.getCategory().getKey());
|
||||
if (kit.getDisplayItem() != null)
|
||||
kitConfig.set("Kits." + kit.getName() + ".displayItem", kit.getDisplayItem().toString());
|
||||
kitConfig.set("Kits." + kit.getKey() + ".displayItem", kit.getDisplayItem().toString());
|
||||
else
|
||||
kitConfig.set("Kits." + kit.getName() + ".displayItem", null);
|
||||
kitConfig.set("Kits." + kit.getKey() + ".displayItem", null);
|
||||
|
||||
List<KitItem> contents = kit.getContents();
|
||||
List<String> strContents = new ArrayList<>();
|
||||
|
||||
for (KitItem item : contents) strContents.add(item.getSerialized());
|
||||
|
||||
kitConfig.set("Kits." + kit.getName() + ".items", strContents);
|
||||
kitConfig.set("Kits." + kit.getKey() + ".items", strContents);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save categories from CategoryManager to Configuration.
|
||||
*/
|
||||
for (Category category : categoryManager.getCategories()) {
|
||||
categoryConfig.set("Categories." + category.getKey() + ".name", category.getName());
|
||||
categoryConfig.set("Categories." + category.getKey() + ".material", category.getMaterial().name());
|
||||
}
|
||||
|
||||
|
||||
// Save to file
|
||||
kitConfig.saveChanges();
|
||||
categoryConfig.saveChanges();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -504,4 +548,8 @@ public class UltimateKits extends SongodaPlugin {
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public CategoryManager getCategoryManager() {
|
||||
return categoryManager;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.songoda.ultimatekits.category;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Category {
|
||||
|
||||
private final String key;
|
||||
private String name;
|
||||
private Material material = Material.DIAMOND;
|
||||
|
||||
public Category(String key, String name) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterial(Material material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(key, category.key);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.songoda.ultimatekits.category;
|
||||
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CategoryManager {
|
||||
|
||||
private final UltimateKits plugin;
|
||||
|
||||
private final Map<String, Category> registeredCategories = new LinkedHashMap<>();
|
||||
|
||||
public CategoryManager(UltimateKits plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public Category getCategory(String key) {
|
||||
return registeredCategories.get(key);
|
||||
}
|
||||
|
||||
public Category getCategoryByName(String name) {
|
||||
return registeredCategories.values().stream()
|
||||
.filter(c -> ChatColor.stripColor(TextUtils.formatText(c.getName())).equalsIgnoreCase(name))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public Category addCategory(String key, String name) {
|
||||
Category category = new Category(key, name);
|
||||
registeredCategories.put(key, category);
|
||||
return category;
|
||||
}
|
||||
|
||||
public void removeCategory(Category category) {
|
||||
registeredCategories.remove(category.getKey());
|
||||
for (Kit kit : plugin.getKitManager().getKits())
|
||||
if (kit.getCategory() == category)
|
||||
kit.setCategory(null);
|
||||
}
|
||||
|
||||
public List<Category> getCategories() {
|
||||
return new LinkedList(registeredCategories.values());
|
||||
}
|
||||
|
||||
public void clearCategories() {
|
||||
registeredCategories.clear();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.songoda.ultimatekits.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.gui.CategoryEditorGui;
|
||||
import com.songoda.ultimatekits.gui.KitEditorGui;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandCategories extends AbstractCommand {
|
||||
|
||||
final UltimateKits plugin = UltimateKits.getInstance();
|
||||
final GuiManager guiManager;
|
||||
|
||||
public CommandCategories(GuiManager guiManager) {
|
||||
super(CommandType.PLAYER_ONLY, "categories");
|
||||
this.guiManager = guiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
guiManager.showGUI((Player)sender, new CategoryEditorGui(plugin, (Player)sender));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "ultimatekits.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/KitAdmin categories";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Open the category editor.";
|
||||
}
|
||||
}
|
@ -54,7 +54,7 @@ public class CommandEdit extends AbstractCommand {
|
||||
List<String> tab = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (Kit kit : UltimateKits.getInstance().getKitManager().getKits())
|
||||
tab.add(kit.getName());
|
||||
tab.add(kit.getKey());
|
||||
return tab;
|
||||
}
|
||||
return tab;
|
||||
|
@ -60,14 +60,14 @@ public class CommandKey extends AbstractCommand {
|
||||
if (playerTo != null) {
|
||||
PlayerUtils.giveItem(playerTo, key.getKeyItem(kit, amt));
|
||||
instance.getLocale().getMessage("event.key.given")
|
||||
.processPlaceholder("kit", kit == null ? "Any" : kit.getShowableName())
|
||||
.processPlaceholder("kit", kit == null ? "Any" : kit.getName())
|
||||
.sendPrefixedMessage(playerTo);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
for (Player pl : instance.getServer().getOnlinePlayers()) {
|
||||
PlayerUtils.giveItem(pl, key.getKeyItem(kit, amt));
|
||||
instance.getLocale().getMessage("event.key.given")
|
||||
.processPlaceholder("kit", kit == null ? "Any" : kit.getShowableName())
|
||||
.processPlaceholder("kit", kit == null ? "Any" : kit.getName())
|
||||
.sendPrefixedMessage(pl);
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
@ -82,7 +82,7 @@ public class CommandKey extends AbstractCommand {
|
||||
if (args.length == 1) {
|
||||
tab.add("all");
|
||||
for (Kit kit : UltimateKits.getInstance().getKitManager().getKits())
|
||||
tab.add(kit.getName());
|
||||
tab.add(kit.getKey());
|
||||
return tab;
|
||||
} else if (args.length == 2) {
|
||||
for (Key key : UltimateKits.getInstance().getKeyManager().getKeys())
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.ultimatekits.commands;
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.gui.CategorySelectorGui;
|
||||
import com.songoda.ultimatekits.gui.KitSelectorGui;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -28,7 +29,10 @@ public class CommandKit extends AbstractCommand {
|
||||
|
||||
if (args.length == 0 && sender instanceof Player) {
|
||||
// /kit - Opens GUI.
|
||||
guiManager.showGUI((Player) sender, new KitSelectorGui(instance, (Player) sender));
|
||||
if (instance.getKitManager().getKits().stream().anyMatch(kit -> kit.getCategory() != null))
|
||||
guiManager.showGUI((Player) sender, new CategorySelectorGui(instance, (Player) sender));
|
||||
else
|
||||
guiManager.showGUI((Player) sender, new KitSelectorGui(instance, (Player) sender, null));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@ -45,7 +49,7 @@ public class CommandKit extends AbstractCommand {
|
||||
return ReturnType.NEEDS_PLAYER;
|
||||
|
||||
|
||||
if (!kit.hasPermission((Player)sender)) {
|
||||
if (!kit.hasPermission((Player) sender)) {
|
||||
instance.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
@ -71,18 +75,18 @@ public class CommandKit extends AbstractCommand {
|
||||
if (player != null) {
|
||||
kit.processGenericUse(player, true);
|
||||
instance.getLocale().getMessage("event.claim.givesuccess")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.sendPrefixedMessage(sender);
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> {
|
||||
kit.processGenericUse(onlinePlayer, true);
|
||||
instance.getLocale().getMessage("event.claim.givesuccess")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.sendPrefixedMessage(sender);
|
||||
});
|
||||
}
|
||||
|
||||
instance.getLocale().newMessage("&7You gave &9" + who + "&7 kit &9" + kit.getShowableName() + "&7.")
|
||||
instance.getLocale().newMessage("&7You gave &9" + who + "&7 kit &9" + kit.getName() + "&7.")
|
||||
.sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
@ -97,7 +101,7 @@ public class CommandKit extends AbstractCommand {
|
||||
if (!(sender instanceof Player)) return tab;
|
||||
|
||||
if (args.length == 1) {
|
||||
for (Kit kit : instance.getKitManager().getKits()) tab.add(kit.getName());
|
||||
for (Kit kit : instance.getKitManager().getKits()) tab.add(kit.getKey());
|
||||
} else if (args.length == 2) {
|
||||
tab.add("all");
|
||||
Bukkit.getOnlinePlayers().forEach(player -> tab.add(player.getName()));
|
||||
|
@ -45,7 +45,7 @@ public class CommandPreviewKit extends AbstractCommand {
|
||||
if (args.length == 2) {
|
||||
List<String> tab = new ArrayList<>();
|
||||
for (Kit kit : UltimateKits.getInstance().getKitManager().getKits()) {
|
||||
tab.add(kit.getName());
|
||||
tab.add(kit.getKey());
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class CommandRemove extends AbstractCommand {
|
||||
.forEach(data -> instance.removeHologram(data));
|
||||
}
|
||||
|
||||
instance.getLocale().newMessage("&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType().toString() + "&8.").sendPrefixedMessage(player);
|
||||
instance.getLocale().newMessage("&8Kit &9" + kit.getKey() + " &8unassigned from: &a" + block.getType().toString() + "&8.").sendPrefixedMessage(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class CommandSet extends AbstractCommand {
|
||||
Block b = player.getTargetBlock(null, 200);
|
||||
KitBlockData data = instance.getKitManager().addKitToLocation(kit, b.getLocation());
|
||||
UltimateKits.getInstance().getDataManager().createBlockData(data);
|
||||
instance.getLocale().newMessage("&8Kit &a" + kit.getName() + " &8set to: &a" + b.getType().toString() + "&8.")
|
||||
instance.getLocale().newMessage("&8Kit &a" + kit.getKey() + " &8set to: &a" + b.getType().toString() + "&8.")
|
||||
.sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
|
||||
@ -49,7 +49,7 @@ public class CommandSet extends AbstractCommand {
|
||||
if (args.length == 1) {
|
||||
List<String> tab = new ArrayList<>();
|
||||
for (Kit kit : UltimateKits.getInstance().getKitManager().getKits()) {
|
||||
tab.add(kit.getName());
|
||||
tab.add(kit.getKey());
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
for (KitBlockData data : blockData.values()) {
|
||||
if (data == null || data.getWorld() == null) continue;
|
||||
statement.setString(1, data.getType().toString());
|
||||
statement.setString(2, data.getKit().getName());
|
||||
statement.setString(2, data.getKit().getKey());
|
||||
statement.setBoolean(3, data.showHologram());
|
||||
statement.setBoolean(4, data.isDisplayingItems());
|
||||
statement.setBoolean(5, data.hasParticles());
|
||||
@ -58,7 +58,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
"WHERE world = ? AND x = ? AND y = ? AND z = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(updateData)) {
|
||||
statement.setString(1, blockData.getType().toString());
|
||||
statement.setString(2, blockData.getKit().getName());
|
||||
statement.setString(2, blockData.getKit().getKey());
|
||||
statement.setBoolean(3, blockData.showHologram());
|
||||
statement.setBoolean(4, blockData.isDisplayingItems());
|
||||
statement.setBoolean(5, blockData.hasParticles());
|
||||
@ -80,7 +80,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createData)) {
|
||||
statement.setString(1, blockData.getType().toString());
|
||||
statement.setString(2, blockData.getKit().getName());
|
||||
statement.setString(2, blockData.getKit().getKey());
|
||||
statement.setBoolean(3, blockData.showHologram());
|
||||
statement.setBoolean(4, blockData.isDisplayingItems());
|
||||
statement.setBoolean(5, blockData.hasParticles());
|
||||
|
@ -42,7 +42,7 @@ public class AnimatedKitGui extends Gui {
|
||||
this.give = give;
|
||||
setRows(3);
|
||||
setAllowClose(false);
|
||||
setTitle(kit.getShowableName());
|
||||
setTitle(kit.getName());
|
||||
setDefaultItem(GuiUtils.getBorderItem(CompatibleMaterial.GRAY_STAINED_GLASS_PANE));
|
||||
|
||||
// ideally, we'd populate the items in such a way that the end item isn't far from the center when the animation is complete
|
||||
|
@ -21,7 +21,7 @@ public class BlockEditorGui extends Gui {
|
||||
this.kitBlockData = kitBlockData;
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitblock.title")
|
||||
.processPlaceholder("kit", kitBlockData.getKit().getShowableName())
|
||||
.processPlaceholder("kit", kitBlockData.getKit().getName())
|
||||
.getMessage());
|
||||
|
||||
// fill glass borders
|
||||
|
@ -0,0 +1,99 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.category.Category;
|
||||
import com.songoda.ultimatekits.category.CategoryManager;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CategoryEditorGui extends Gui {
|
||||
|
||||
private final UltimateKits plugin;
|
||||
private final Player player;
|
||||
private final CategoryManager categoryManager;
|
||||
|
||||
public CategoryEditorGui(UltimateKits plugin, Player player) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.categoryManager = plugin.getCategoryManager();
|
||||
setRows(3);
|
||||
setTitle("Category Editor");
|
||||
setAcceptsItems(true); // display item takes an item
|
||||
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
GuiUtils.mirrorFill(this, 1, 1, false, true, getDefaultItem());
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.GREEN_DYE, "Create Category"),
|
||||
(event) -> {
|
||||
if (categoryManager.getCategories().size() >= 7) {
|
||||
plugin.getLocale().newMessage("&cYou already have the maximum amount of categories...").sendPrefixedMessage(player);
|
||||
} else {
|
||||
ChatPrompt.showPrompt(event.manager.getPlugin(), event.player, "Enter a category name:", response -> {
|
||||
String msg = response.getMessage().trim();
|
||||
|
||||
String key = msg.toUpperCase().replace(" ", "_");
|
||||
|
||||
if (categoryManager.getCategory(key) != null) {
|
||||
plugin.getLocale().newMessage("&cA category with that name already exists...").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
categoryManager.addCategory(key, msg);
|
||||
plugin.getLocale().newMessage("&aCategory added successfully!").sendPrefixedMessage(player);
|
||||
|
||||
player.closeInventory();
|
||||
}).setOnClose(() -> {
|
||||
event.manager.showGUI(event.player, new CategoryEditorGui(plugin, event.player));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// exit button
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
plugin.getLocale().getMessage("interface.button.exit").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> exit());
|
||||
paint();
|
||||
}
|
||||
|
||||
private void paint() {
|
||||
List<Category> categories = categoryManager.getCategories();
|
||||
for (int i = 0; i < categories.size(); i++) {
|
||||
Category category = categories.get(i);
|
||||
setButton(i + 10,
|
||||
GuiUtils.createButtonItem(CompatibleMaterial.getMaterial(category.getMaterial()),
|
||||
TextUtils.formatText(category.getName()),
|
||||
TextUtils.formatText("&6Left click to change name"),
|
||||
"",
|
||||
TextUtils.formatText("&6Middle click to set material"),
|
||||
TextUtils.formatText("&6to item in hand."),
|
||||
"",
|
||||
TextUtils.formatText("&cRight click to remove."),
|
||||
TextUtils.formatText("&c(Kits will not be removed)")),
|
||||
(event) -> {
|
||||
if (event.clickType == ClickType.LEFT)
|
||||
ChatPrompt.showPrompt(event.manager.getPlugin(), event.player, "Enter a name:", response -> {
|
||||
category.setName(response.getMessage().trim());
|
||||
event.manager.showGUI(event.player, new CategoryEditorGui(plugin, event.player));
|
||||
});
|
||||
else if (event.clickType == ClickType.MIDDLE) {
|
||||
category.setMaterial(player.getItemInHand().getType());
|
||||
event.manager.showGUI(event.player, new CategoryEditorGui(plugin, event.player));
|
||||
} else if (event.clickType == ClickType.RIGHT) {
|
||||
categoryManager.removeCategory(category);
|
||||
event.manager.showGUI(event.player, new CategoryEditorGui(plugin, event.player));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.category.Category;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CategorySelectorGui extends Gui {
|
||||
|
||||
private int timer;
|
||||
|
||||
public CategorySelectorGui(UltimateKits plugin, Player player) {
|
||||
boolean glassless = Settings.DO_NOT_USE_GLASS_BORDERS.getBoolean();
|
||||
|
||||
Set<Category> categories = new LinkedHashSet<>();
|
||||
|
||||
for (Kit kit : plugin.getKitManager().getKits())
|
||||
if (kit.hasPermission(player) && kit.getCategory() != null)
|
||||
categories.add(kit.getCategory());
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("interface.categoryselector.title").getMessage());
|
||||
|
||||
int showPerRow = glassless ? 9 : 7;
|
||||
int nrows = (int) Math.ceil(categories.size() / (double) showPerRow);
|
||||
setRows(glassless ? nrows : nrows + 2);
|
||||
|
||||
setItem(0, 4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK,
|
||||
plugin.getLocale().getMessage("interface.categoryselector.details")
|
||||
.processPlaceholder("player", player.getName()).getMessage().split("\\|")));
|
||||
|
||||
if (!glassless) {
|
||||
setButton(rows - 1, 4, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
UltimateKits.getInstance().getLocale().getMessage("interface.button.exit").getMessage()),
|
||||
event -> exit());
|
||||
}
|
||||
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial());
|
||||
setDefaultItem(AIR);
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
|
||||
if (!glassless) {
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
animateGlass();
|
||||
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
if (inventory.getViewers().isEmpty()) return;
|
||||
animateGlass();
|
||||
}, 20L, 20L);
|
||||
setOnClose(event -> Bukkit.getScheduler().cancelTask(timer));
|
||||
} else {
|
||||
ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial());
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 0, 3, false, true, glass1);
|
||||
}
|
||||
}
|
||||
|
||||
int i = 10;
|
||||
for (Category category : categories) {
|
||||
setButton(i, GuiUtils.createButtonItem(CompatibleMaterial.getMaterial(category.getMaterial()),
|
||||
TextUtils.formatText(category.getName()),
|
||||
"",
|
||||
plugin.getLocale().getMessage("interface.categoryselector.view").getMessage()),
|
||||
event -> {
|
||||
guiManager.showGUI(player, new KitSelectorGui(plugin, player, category));
|
||||
});
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static final Random rand = new Random();
|
||||
|
||||
private void animateGlass() {
|
||||
for (int col = 1; col < 8; ++col) {
|
||||
ItemStack it;
|
||||
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() == 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) {
|
||||
setItem(row, 0, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
setItem(row, 8, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class ConfirmBuyGui extends Gui {
|
||||
|
||||
// Kit information
|
||||
setItem(0, 4, GuiUtils.createButtonItem(kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.DIAMOND_HELMET,
|
||||
ChatColor.RED + TextUtils.formatText(kit.getName().toLowerCase(), true),
|
||||
ChatColor.RED + TextUtils.formatText(kit.getKey().toLowerCase(), true),
|
||||
ChatColor.GREEN + Settings.CURRENCY_SYMBOL.getString() + Methods.formatEconomy(cost)));
|
||||
|
||||
// confirm button
|
||||
|
@ -20,7 +20,7 @@ public class KitDecorOptionsGui extends Gui {
|
||||
super(parent);
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitdecor.title")
|
||||
.processPlaceholder("kit", kitBlockData.getKit().getShowableName())
|
||||
.processPlaceholder("kit", kitBlockData.getKit().getName())
|
||||
.getMessage());
|
||||
|
||||
Kit kit = kitBlockData.getKit();
|
||||
|
@ -36,6 +36,8 @@ public class KitEditorGui extends DoubleGui {
|
||||
private boolean isInFunction = false;
|
||||
private boolean isInInventory = false;
|
||||
|
||||
private ItemStack[] stash;
|
||||
|
||||
public KitEditorGui(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||
super(back);
|
||||
this.plugin = plugin;
|
||||
@ -45,12 +47,14 @@ public class KitEditorGui extends DoubleGui {
|
||||
setDefaultItem(null);
|
||||
setRows(6);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kiteditor.title")
|
||||
.processPlaceholder("name", kit.getShowableName())
|
||||
.processPlaceholder("name", kit.getName())
|
||||
.getMessage());
|
||||
|
||||
setInvItems();
|
||||
setOnClose((event) -> {
|
||||
this.saveKit(player, inventory, false);
|
||||
if (!isInInventory)
|
||||
restoreItemsInstance();
|
||||
CompatibleSound.ENTITY_VILLAGER_YES.play(player);
|
||||
});
|
||||
|
||||
@ -80,11 +84,12 @@ public class KitEditorGui extends DoubleGui {
|
||||
// info icon
|
||||
setItem(0, 4, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
|
||||
plugin.getLocale().getMessage("interface.kiteditor.info")
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.processPlaceholder("perm", "ultimatekits.kit." + kit.getName().toLowerCase())
|
||||
.processPlaceholder("kit", kit.getKey())
|
||||
.processPlaceholder("perm", "ultimatekits.kit." + kit.getKey().toLowerCase())
|
||||
.getMessage().split("\\|"))
|
||||
);
|
||||
|
||||
saveItemsInstance();
|
||||
paint();
|
||||
}
|
||||
|
||||
@ -193,7 +198,7 @@ public class KitEditorGui extends DoubleGui {
|
||||
this.setPlayerActionForRange(0, 0, 3, 8, event -> {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if (isInInventory)
|
||||
stash.put(player, player.getInventory().getContents().clone());
|
||||
stash = player.getInventory().getContents().clone();
|
||||
}, 0L);
|
||||
if (!isInInventory && event.player.getItemOnCursor().getType() != Material.AIR) {
|
||||
event.event.setCancelled(true);
|
||||
@ -203,14 +208,15 @@ public class KitEditorGui extends DoubleGui {
|
||||
|
||||
private void saveItemsInstance() {
|
||||
setPlayerUnlockedRange(0, 0, 3, 8, false);
|
||||
stash.put(player, player.getInventory().getContents().clone());
|
||||
stash = player.getInventory().getContents().clone();
|
||||
player.getInventory().clear();
|
||||
isInInventory = false;
|
||||
}
|
||||
|
||||
private void restoreItemsInstance() {
|
||||
setPlayerUnlockedRange(0, 0, 3, 8);
|
||||
player.getInventory().setContents(stash.get(player));
|
||||
if (stash != null)
|
||||
player.getInventory().setContents(stash);
|
||||
player.updateInventory();
|
||||
isInInventory = true;
|
||||
}
|
||||
@ -339,7 +345,7 @@ public class KitEditorGui extends DoubleGui {
|
||||
kit.saveKit(Arrays.asList(items));
|
||||
if (!muteSave)
|
||||
plugin.getLocale().getMessage("interface.kiteditor.saved")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.sendPrefixedMessage(player);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.category.Category;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
@ -18,7 +19,7 @@ public class KitGeneralOptionsGui extends Gui {
|
||||
super(back);
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitoptions.title")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.getMessage());
|
||||
|
||||
// fill glass borders
|
||||
@ -40,7 +41,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());
|
||||
@ -62,16 +63,43 @@ public class KitGeneralOptionsGui extends Gui {
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
// edit category
|
||||
setButton(1, 4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK,
|
||||
plugin.getLocale().getMessage("interface.kitoptions.category").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitoptions.categorylore")
|
||||
.processPlaceholder("category", kit.getCategory() == null ? "none" : kit.getCategory().getName()).getMessage().split("\\|")),
|
||||
event -> {
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.categoryprompt").getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText().trim();
|
||||
Category category = plugin.getCategoryManager().getCategoryByName(msg);
|
||||
if (category != null) {
|
||||
kit.setCategory(category);
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitoptions.categorylore")
|
||||
.processPlaceholder("category", kit.getCategory() == null ? "none" : kit.getCategory().getName()).getMessage().split("\\|"));
|
||||
aevent.player.closeInventory();
|
||||
return;
|
||||
}
|
||||
plugin.getLocale().getMessage("interface.kitoptions.notacategory").processPlaceholder("input", msg).sendPrefixedMessage(player);
|
||||
});
|
||||
guiManager.showGUI(event.player, gui);
|
||||
} else if (event.clickType == ClickType.RIGHT) {
|
||||
kit.setCategory(null);
|
||||
}
|
||||
});
|
||||
|
||||
// delete
|
||||
setButton(1, 6, GuiUtils.createButtonItem(CompatibleMaterial.TNT,
|
||||
plugin.getLocale().getMessage("interface.kitoptions.destroy").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitoptions.destroylore").getMessage().split("\\|")),
|
||||
event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.destroyprompt").processPlaceholder("kit", kit.getName()).getMessage());
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.destroyprompt").processPlaceholder("kit", kit.getKey()).getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText();
|
||||
if (msg != null && msg.trim().equalsIgnoreCase(kit.getName())) {
|
||||
if (msg != null && msg.trim().equalsIgnoreCase(kit.getKey())) {
|
||||
plugin.getKitManager().removeKit(kit);
|
||||
plugin.updateHologram(kit);
|
||||
plugin.getLocale().getMessage("interface.kitoptions.destroyok").sendPrefixedMessage(player);
|
||||
|
@ -27,7 +27,7 @@ public class KitGuiOptionsGui extends Gui {
|
||||
this.player = player;
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitblock.title")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.getMessage());
|
||||
setAcceptsItems(true); // display item takes an item
|
||||
|
||||
@ -66,7 +66,7 @@ public class KitGuiOptionsGui extends Gui {
|
||||
kit.setTitle(msg);
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.holoset")
|
||||
.processPlaceholder("title", msg)
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.sendPrefixedMessage(player);
|
||||
|
||||
plugin.updateHologram(kit);
|
||||
@ -95,13 +95,13 @@ public class KitGuiOptionsGui extends Gui {
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemnoitem").sendPrefixedMessage(player);
|
||||
} else {
|
||||
kit.setDisplayItem(is);
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemset").processPlaceholder("item", kit.getShowableName()).sendPrefixedMessage(player);
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemset").processPlaceholder("item", kit.getName()).sendPrefixedMessage(player);
|
||||
paint();
|
||||
}
|
||||
});
|
||||
setAction(1, 4, ClickType.RIGHT, event -> {
|
||||
kit.setDisplayItem((ItemStack) null);
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemremoved").processPlaceholder("kit", kit.getShowableName()).sendPrefixedMessage(player);
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemremoved").processPlaceholder("kit", kit.getName()).sendPrefixedMessage(player);
|
||||
paint();
|
||||
});
|
||||
|
||||
|
@ -6,14 +6,10 @@ import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.category.Category;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -21,21 +17,29 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class KitSelectorGui extends Gui {
|
||||
|
||||
private Player player;
|
||||
private UltimateKits plugin;
|
||||
|
||||
private int timer;
|
||||
private Category category;
|
||||
private List<String> kitList;
|
||||
private boolean kitsmode = false;
|
||||
|
||||
private boolean glassless;
|
||||
private int showPerRow, showPerPage;
|
||||
|
||||
public KitSelectorGui(UltimateKits plugin, Player player) {
|
||||
public KitSelectorGui(UltimateKits plugin, Player player, Category category) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.category = category;
|
||||
glassless = Settings.DO_NOT_USE_GLASS_BORDERS.getBoolean();
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("interface.selector.title").getMessage());
|
||||
@ -48,7 +52,7 @@ public class KitSelectorGui extends Gui {
|
||||
|
||||
setItem(0, 4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK,
|
||||
plugin.getLocale().getMessage("interface.selector.details")
|
||||
.processPlaceholder("player", player.getName()).getMessage().split("\\|")));
|
||||
.processPlaceholder("player", player.getName()).getMessage().split("\\|")));
|
||||
|
||||
if (pages > 1) {
|
||||
this.setNextPage(rows - 1, 5, GuiUtils.createButtonItem(ItemUtils.getCustomHead("1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b"),
|
||||
@ -70,8 +74,8 @@ public class KitSelectorGui extends Gui {
|
||||
setDefaultItem(AIR);
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
|
||||
if(!glassless) {
|
||||
if(Settings.RAINBOW.getBoolean()) {
|
||||
if (!glassless) {
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
animateGlass();
|
||||
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
if (inventory.getViewers().isEmpty()) return;
|
||||
@ -89,27 +93,35 @@ public class KitSelectorGui extends Gui {
|
||||
}
|
||||
}
|
||||
|
||||
if (category != null)
|
||||
setButton(0, 0, GuiUtils.createButtonItem(ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("interface.button.back").getMessage()),
|
||||
event -> guiManager.showGUI(player, new CategorySelectorGui(plugin, player)));
|
||||
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void loadKits() {
|
||||
boolean showAll = !Settings.ONLY_SHOW_KITS_WITH_PERMS.getBoolean();
|
||||
kitList = plugin.getKitManager().getKits().stream()
|
||||
.filter(kit -> !kit.isHidden() && (showAll || kit.hasPermission(player)))
|
||||
.map(kit -> kit.getName())
|
||||
.filter(kit -> !kit.isHidden() && (showAll || kit.hasPermission(player))
|
||||
&& (category == null || kit.getCategory() == category))
|
||||
.map(Kit::getKey)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
static final Random rand = new Random();
|
||||
|
||||
private void animateGlass() {
|
||||
for(int col = 1; col < 8; ++col) {
|
||||
for (int col = 1; col < 8; ++col) {
|
||||
ItemStack it;
|
||||
if((it = getItem(0, col)) == null || it.getType() == Material.AIR || 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() == Material.AIR || 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) {
|
||||
for (int row = 1; row + 1 < rows; ++row) {
|
||||
setItem(row, 0, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
setItem(row, 8, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
@ -119,7 +131,7 @@ public class KitSelectorGui extends Gui {
|
||||
int index = (page - 1) * showPerPage;
|
||||
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()) {
|
||||
if (index >= kitList.size()) {
|
||||
setItem(row, col, null);
|
||||
clearActions(row, col);
|
||||
continue;
|
||||
@ -160,50 +172,50 @@ public class KitSelectorGui extends Gui {
|
||||
|
||||
private List<String> getKitLore(Kit kit) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
if (kit.getPrice() != 0)
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.aboutkitprice")
|
||||
.processPlaceholder("price", String.valueOf(kit.getPrice()))
|
||||
.getMessage());
|
||||
else if (kit.getLink() != null)
|
||||
lore.add(plugin.getLocale().getMessage("general.type.link").getMessage());
|
||||
if (kit.getPrice() != 0)
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.aboutkitprice")
|
||||
.processPlaceholder("price", String.valueOf(kit.getPrice()))
|
||||
.getMessage());
|
||||
else if (kit.getLink() != null)
|
||||
lore.add(plugin.getLocale().getMessage("general.type.link").getMessage());
|
||||
|
||||
if (!kitsmode) {
|
||||
if (!plugin.getLocale().getMessage("interface.selector.aboutkit").getMessage().trim().equals("")) {
|
||||
String[] parts = plugin.getLocale().getMessage("interface.selector.aboutkit").getMessage().split("\\|");
|
||||
lore.add("");
|
||||
for (String line : parts)
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
if (kit.hasPermission(player)) {
|
||||
if (kit.getNextUse(player) == -1) {
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.once").getMessage());
|
||||
} else if (kit.getNextUse(player) > 0) {
|
||||
if (!plugin.getLocale().getMessage("event.claim.wait").getMessage().trim().equals("")) {
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.wait")
|
||||
.processPlaceholder("time", Methods.makeReadable(kit.getNextUse(player)))
|
||||
.getMessage());
|
||||
}
|
||||
} else if (!plugin.getLocale().getMessage("event.claim.ready").getMessage().trim().equals("")) {
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.ready").getMessage());
|
||||
}
|
||||
} else
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.noaccess").getMessage());
|
||||
if (!kitsmode) {
|
||||
if (!plugin.getLocale().getMessage("interface.selector.aboutkit").getMessage().trim().equals("")) {
|
||||
String[] parts = plugin.getLocale().getMessage("interface.selector.aboutkit").getMessage().split("\\|");
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.leftpreview").getMessage());
|
||||
if (kit.hasPermission(player)) {
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.rightclaim").getMessage());
|
||||
} else if (kit.getPrice() != 0 || kit.getLink() != null) {
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.rightbuy").getMessage());
|
||||
}
|
||||
|
||||
if (player.hasPermission("ultimatekits.admin")) {
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.adminlore").getMessage());
|
||||
}
|
||||
} else {
|
||||
lore.addAll(Arrays.asList(plugin.getLocale().getMessage("interface.selector.editlore").getMessage().split("\\|")));
|
||||
for (String line : parts)
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
return lore;
|
||||
if (kit.hasPermission(player)) {
|
||||
if (kit.getNextUse(player) == -1) {
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.once").getMessage());
|
||||
} else if (kit.getNextUse(player) > 0) {
|
||||
if (!plugin.getLocale().getMessage("event.claim.wait").getMessage().trim().equals("")) {
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.wait")
|
||||
.processPlaceholder("time", Methods.makeReadable(kit.getNextUse(player)))
|
||||
.getMessage());
|
||||
}
|
||||
} else if (!plugin.getLocale().getMessage("event.claim.ready").getMessage().trim().equals("")) {
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.ready").getMessage());
|
||||
}
|
||||
} else
|
||||
lore.add(plugin.getLocale().getMessage("event.claim.noaccess").getMessage());
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.leftpreview").getMessage());
|
||||
if (kit.hasPermission(player)) {
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.rightclaim").getMessage());
|
||||
} else if (kit.getPrice() != 0 || kit.getLink() != null) {
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.rightbuy").getMessage());
|
||||
}
|
||||
|
||||
if (player.hasPermission("ultimatekits.admin")) {
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("interface.selector.adminlore").getMessage());
|
||||
}
|
||||
} else {
|
||||
lore.addAll(Arrays.asList(plugin.getLocale().getMessage("interface.selector.editlore").getMessage().split("\\|")));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import java.util.Random;
|
||||
|
||||
public class KitSellingOptionsGui extends Gui {
|
||||
|
||||
@ -27,7 +26,7 @@ public class KitSellingOptionsGui extends Gui {
|
||||
this.kit = kit;
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitblock.title")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.processPlaceholder("kit", kit.getName())
|
||||
.getMessage());
|
||||
|
||||
// fill glass borders
|
||||
|
@ -27,7 +27,6 @@ public class PreviewKitGui extends Gui {
|
||||
private final boolean buyable;
|
||||
private final List<ItemStack> list;
|
||||
private final boolean useGlassBorder = !Settings.DO_NOT_USE_GLASS_BORDERS.getBoolean();
|
||||
static final Random rand = new Random();
|
||||
|
||||
public PreviewKitGui(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||
super(back);
|
||||
@ -38,7 +37,7 @@ public class PreviewKitGui extends Gui {
|
||||
this.buyable = (kit.getLink() != null || kit.getPrice() != 0);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("interface.preview.title")
|
||||
.processPlaceholder("kit", kit.getTitle() != null ? TextUtils.formatText(kit.getTitle(), true) : kit.getShowableName()).getMessage());
|
||||
.processPlaceholder("kit", kit.getTitle() != null ? TextUtils.formatText(kit.getTitle(), true) : kit.getName()).getMessage());
|
||||
|
||||
int amt = 0;
|
||||
for (ItemStack is : list) {
|
||||
|
@ -36,7 +36,7 @@ public class Key {
|
||||
|
||||
String kitName;
|
||||
if (kit != null)
|
||||
kitName = TextUtils.formatText(kit.getShowableName(), true);
|
||||
kitName = TextUtils.formatText(kit.getName(), true);
|
||||
else
|
||||
kitName = "Any";
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.category.Category;
|
||||
import com.songoda.ultimatekits.gui.AnimatedKitGui;
|
||||
import com.songoda.ultimatekits.gui.ConfirmBuyGui;
|
||||
import com.songoda.ultimatekits.gui.PreviewKitGui;
|
||||
@ -32,7 +33,9 @@ import java.util.*;
|
||||
*/
|
||||
public class Kit {
|
||||
|
||||
private final String name, showableName;
|
||||
private final String key, name;
|
||||
private Category category = null;
|
||||
|
||||
private static UltimateKits plugin;
|
||||
private double price = 0;
|
||||
private String link, title = null;
|
||||
@ -42,11 +45,11 @@ public class Kit {
|
||||
private List<KitItem> contents = new ArrayList<>();
|
||||
private KitAnimation kitAnimation = KitAnimation.NONE;
|
||||
|
||||
public Kit(String name) {
|
||||
public Kit(String key) {
|
||||
if (plugin == null)
|
||||
plugin = UltimateKits.getInstance();
|
||||
this.name = name;
|
||||
this.showableName = TextUtils.formatText(name, true);
|
||||
this.key = key;
|
||||
this.name = TextUtils.formatText(key, true);
|
||||
}
|
||||
|
||||
public void buy(Player player, GuiManager manager) {
|
||||
@ -55,7 +58,7 @@ public class Kit {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasPermission("ultimatekits.buy." + name)) {
|
||||
if (!player.hasPermission("ultimatekits.buy." + key)) {
|
||||
UltimateKits.getInstance().getLocale().getMessage("command.general.noperms")
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
@ -105,7 +108,7 @@ public class Kit {
|
||||
Key key = plugin.getKeyManager().getKey(ChatColor.stripColor(item.getItemMeta().getLore().get(0)).replace(" Key", ""));
|
||||
|
||||
if (!item.getItemMeta().getDisplayName().equals(plugin.getLocale().getMessage("interface.key.title")
|
||||
.processPlaceholder("kit", showableName).getMessage())
|
||||
.processPlaceholder("kit", name).getMessage())
|
||||
&& !item.getItemMeta().getDisplayName().equals(plugin.getLocale().getMessage("interface.key.title")
|
||||
.processPlaceholder("kit", "Any").getMessage())) {
|
||||
plugin.getLocale().getMessage("event.crate.wrongkey").sendPrefixedMessage(player);
|
||||
@ -113,7 +116,7 @@ public class Kit {
|
||||
}
|
||||
if (giveKit(player, key)) {
|
||||
plugin.getLocale().getMessage("event.key.success")
|
||||
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
|
||||
.processPlaceholder("kit", name).sendPrefixedMessage(player);
|
||||
if (player.getInventory().getItemInHand().getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
player.setItemInHand(item);
|
||||
@ -126,13 +129,13 @@ public class Kit {
|
||||
public void processPurchaseUse(Player player) {
|
||||
if (!EconomyManager.isEnabled()) return;
|
||||
|
||||
if (!player.hasPermission("ultimatekits.buy." + name)) {
|
||||
if (!player.hasPermission("ultimatekits.buy." + key)) {
|
||||
UltimateKits.getInstance().getLocale().getMessage("command.general.noperms")
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
} else if (!EconomyManager.hasBalance(player, price)) {
|
||||
plugin.getLocale().getMessage("event.claim.cannotafford")
|
||||
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
|
||||
.processPlaceholder("kit", name).sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
if (this.delay > 0) {
|
||||
@ -152,7 +155,7 @@ public class Kit {
|
||||
updateDelay(player); //updates delay on buy
|
||||
|
||||
plugin.getLocale().getMessage("event.claim.purchasesuccess")
|
||||
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
|
||||
.processPlaceholder("kit", name).sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +167,7 @@ public class Kit {
|
||||
updateDelay(player);
|
||||
if (kitAnimation == KitAnimation.NONE)
|
||||
plugin.getLocale().getMessage("event.claim.givesuccess")
|
||||
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
|
||||
.processPlaceholder("kit", name).sendPrefixedMessage(player);
|
||||
}
|
||||
} else {
|
||||
plugin.getLocale().getMessage("event.claim.delay")
|
||||
@ -176,20 +179,20 @@ public class Kit {
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void display(Player player, GuiManager manager, Gui back) {
|
||||
if (!player.hasPermission("previewkit.use")
|
||||
&& !player.hasPermission("previewkit." + name)
|
||||
&& !player.hasPermission("previewkit." + key)
|
||||
&& !player.hasPermission("ultimatekits.use")
|
||||
&& !player.hasPermission("ultimatekits." + name)) {
|
||||
&& !player.hasPermission("ultimatekits." + key)) {
|
||||
UltimateKits.getInstance().getLocale().getMessage("command.general.noperms")
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
if (name == null) {
|
||||
if (key == null) {
|
||||
plugin.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLocale().getMessage("event.preview.kit")
|
||||
.processPlaceholder("kit", showableName).sendPrefixedMessage(player);
|
||||
.processPlaceholder("kit", name).sendPrefixedMessage(player);
|
||||
manager.showGUI(player, new PreviewKitGui(plugin, player, this, back));
|
||||
}
|
||||
|
||||
@ -353,11 +356,11 @@ public class Kit {
|
||||
}
|
||||
|
||||
public void updateDelay(Player player) {
|
||||
plugin.getDataFile().set("Kits." + name + ".delays." + player.getUniqueId().toString(), System.currentTimeMillis());
|
||||
plugin.getDataFile().set("Kits." + key + ".delays." + player.getUniqueId().toString(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public Long getNextUse(Player player) {
|
||||
String configSectionPlayer = "Kits." + name + ".delays." + player.getUniqueId().toString();
|
||||
String configSectionPlayer = "Kits." + key + ".delays." + player.getUniqueId().toString();
|
||||
Config config = plugin.getDataFile();
|
||||
|
||||
if (!config.contains(configSectionPlayer)) {
|
||||
@ -371,9 +374,9 @@ public class Kit {
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player) {
|
||||
if (player.hasPermission("uc.kit." + name.toLowerCase())) return true;
|
||||
if (player.hasPermission("essentials.kit." + name.toLowerCase())) return true;
|
||||
if (player.hasPermission("ultimatekits.kit." + name.toLowerCase())) return true;
|
||||
if (player.hasPermission("uc.kit." + key.toLowerCase())) return true;
|
||||
if (player.hasPermission("essentials.kit." + key.toLowerCase())) return true;
|
||||
if (player.hasPermission("ultimatekits.kit." + key.toLowerCase())) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -413,6 +416,15 @@ public class Kit {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public Kit setCategory(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<KitItem> getContents() {
|
||||
return this.contents;
|
||||
}
|
||||
@ -422,12 +434,12 @@ public class Kit {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getShowableName() {
|
||||
return showableName;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CompatibleMaterial getDisplayItem() {
|
||||
@ -463,7 +475,7 @@ public class Kit {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (name != null ? name.hashCode() : 0);
|
||||
return 31 * (key != null ? key.hashCode() : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -472,7 +484,7 @@ public class Kit {
|
||||
if (!(o instanceof Kit)) return false;
|
||||
|
||||
Kit kit = (Kit) o;
|
||||
return Objects.equals(name, kit.name);
|
||||
return Objects.equals(key, kit.key);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,20 +44,20 @@ public class KitItem {
|
||||
ItemStack itemStack = item.clone();
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (itemStack.hasItemMeta() && meta.hasDisplayName() && meta.getDisplayName().contains(";")) {
|
||||
translateLine(meta.getDisplayName());
|
||||
String[] split = meta.getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "").split(";", 2);
|
||||
meta.setDisplayName(split[1].contains("faqe") ? null : meta.getDisplayName().split(";", 2)[1]);
|
||||
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);
|
||||
}
|
||||
String line = itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() ? meta.getDisplayName() : "";
|
||||
|
||||
processContent(line, item);
|
||||
processContent(null, itemStack);
|
||||
}
|
||||
|
||||
private void processContent(String line, ItemStack item) {
|
||||
if (line.startsWith(Settings.CURRENCY_SYMBOL.getString())) {
|
||||
if (line != null && line.startsWith(Settings.CURRENCY_SYMBOL.getString())) {
|
||||
this.content = new KitContentEconomy(Double.parseDouble(line.substring(1).trim()));
|
||||
} else if (line.startsWith("/")) {
|
||||
} else if (line != null && line.startsWith("/")) {
|
||||
this.content = new KitContentCommand(line.substring(1));
|
||||
} else {
|
||||
ItemStack itemStack = item == null ? UltimateKits.getInstance().getItemSerializer().deserializeItemStackFromJson(line) : item;
|
||||
@ -153,7 +153,7 @@ public class KitItem {
|
||||
}
|
||||
|
||||
public ItemStack getMoveableItem() {
|
||||
if(content == null) return null;
|
||||
if (content == null) return null;
|
||||
ItemStack item = content.getItemForDisplay();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (chance != 0 || displayItem != null || displayName != null || displayLore != null) {
|
||||
@ -168,14 +168,14 @@ public class KitItem {
|
||||
}
|
||||
|
||||
public ItemStack getItemForDisplay() {
|
||||
if(content == null) return null;
|
||||
if (content == null) return null;
|
||||
ItemStack item = content.getItemForDisplay();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (displayItem != null) {
|
||||
item.setType(displayItem);
|
||||
}
|
||||
if(meta != null) {
|
||||
if (meta != null) {
|
||||
if (displayName != null) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public final class KitManager {
|
||||
}
|
||||
|
||||
public Kit getKit(String name) {
|
||||
return registeredKits.stream().filter(kit -> kit.getName().equalsIgnoreCase(name.trim()))
|
||||
return registeredKits.stream().filter(kit -> kit.getKey().equalsIgnoreCase(name.trim()))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class BlockListeners implements Listener {
|
||||
|
||||
instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
|
||||
instance.getLocale().newMessage("&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8.")
|
||||
instance.getLocale().newMessage("&8Kit &9" + kit.getKey() + " &8unassigned from: &a" + block.getType() + "&8.")
|
||||
.sendPrefixedMessage(event.getPlayer());
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ general:
|
||||
type:
|
||||
command: '&7Command'
|
||||
chance: Chance
|
||||
category: Category
|
||||
money: '&6Money'
|
||||
link: '&9Link'
|
||||
free: Free
|
||||
@ -24,6 +25,10 @@ interface:
|
||||
rightbuy: '&6&lRIGHT CLICK &7to buy kit.'
|
||||
adminlore: '&6Middle Click &7to edit positioning.'
|
||||
editlore: '&6&lEdit Mode||&6Left Click &7to move kit left|&6Right Click &7to move kit right||&6Middle Click &7to go back.'
|
||||
categoryselector:
|
||||
title: '&8Server Kit Categories'
|
||||
details: '&7Hello &e%player%&7!|&7Listed below are our server''s kits.||&7Click on a &ecategory &7to view |&7the contained kits.'
|
||||
view: '&6&lCLICK &7to view category.'
|
||||
hologram:
|
||||
previewonly: Click to Preview!
|
||||
preview: Right-Click to Preview!
|
||||
@ -115,6 +120,10 @@ interface:
|
||||
delaylore: '&7Currently set to: &a%delay%&7.||&7Use this to alter this kit delay.||&7Use &6-1 &7to make this kit single|&7use only.'
|
||||
delayprompt: 'Delay in Seconds:'
|
||||
delaynonumber: '&a%input% &8is not a number.'
|
||||
category: '&5&lSet Category'
|
||||
categorylore: '&7Currently set to: &a%category%&7.||&7Adding this kit to a category will|&7cause it do be displayed in|&7that category.||&cRight click to remove.'
|
||||
categoryprompt: 'Category name:'
|
||||
notacategory: '&cThat is not a category...'
|
||||
destroy: '&c&lDestroy Kit'
|
||||
destroylore: '|&7Click this to destroy this kit.'
|
||||
destroyprompt: Enter "%kit%"
|
||||
@ -147,7 +156,7 @@ interface:
|
||||
switchtoinventorylore: '&7Click to switch to|&7your inventory.'
|
||||
switchtokitfunctions: '&6Switch To Kit Functions'
|
||||
switchtokitfunctionslore: '&7Click to switch back|&7to the kit functions.'
|
||||
itemfunctionlore: '&7Display Item: &6%item%|&7Display Name: &6%name%|&7Display Lore: &6||&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.'
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user