Removed arconix.

This commit is contained in:
Brianna O'Keefe 2019-02-14 06:55:04 -05:00
parent 4d8d4202ee
commit 8d56a71486
38 changed files with 820 additions and 445 deletions

View File

@ -113,9 +113,10 @@
<version>7.3.0</version>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>epicspawners</artifactId>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.gmail.nossr50</groupId>

View File

@ -1,25 +1,22 @@
package com.songoda.ultimatekits;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.api.utils.ConfigWrapper;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.command.CommandManager;
import com.songoda.ultimatekits.conversion.Convert;
import com.songoda.ultimatekits.events.*;
import com.songoda.ultimatekits.handlers.DisplayItemHandler;
import com.songoda.ultimatekits.handlers.HologramHandler;
import com.songoda.ultimatekits.handlers.ParticleHandler;
import com.songoda.ultimatekits.hologram.Hologram;
import com.songoda.ultimatekits.hologram.HologramArconix;
import com.songoda.ultimatekits.key.Key;
import com.songoda.ultimatekits.key.KeyManager;
import com.songoda.ultimatekits.kit.*;
import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.ItemSerializer;
import com.songoda.ultimatekits.utils.SettingsManager;
import com.songoda.ultimatekits.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
@ -41,8 +38,8 @@ public class UltimateKits extends JavaPlugin {
private KitManager kitManager;
private CommandManager commandManager;
private KeyManager keyManager;
private HologramHandler hologramHandler;
private DisplayItemHandler displayItemHandler;
private Hologram hologram;
private ItemSerializer itemSerializer;
@ -81,18 +78,17 @@ public class UltimateKits extends JavaPlugin {
if (!checkVersion()) return;
INSTANCE = this;
Arconix.pl().hook(this);
console.sendMessage(TextComponent.formatText("&a============================="));
console.sendMessage(TextComponent.formatText("&7UltimateKits " + this.getDescription().getVersion() + " by &5Songoda <3!"));
console.sendMessage(TextComponent.formatText("&7Action: &aEnabling&7..."));
console.sendMessage(Methods.formatText("&a============================="));
console.sendMessage(Methods.formatText("&7UltimateKits " + this.getDescription().getVersion() + " by &5Songoda <3!"));
console.sendMessage(Methods.formatText("&7Action: &aEnabling&7..."));
this.loadLanguageFile();
try {
this.itemSerializer = new ItemSerializer();
} catch (NoSuchMethodException | SecurityException | ClassNotFoundException e) {
console.sendMessage(TextComponent.formatText("&cCould not load the serialization class! Please report this error."));
console.sendMessage(Methods.formatText("&cCould not load the serialization class! Please report this error."));
e.printStackTrace();
}
@ -110,19 +106,26 @@ public class UltimateKits extends JavaPlugin {
this.kitManager = new KitManager();
this.keyManager = new KeyManager();
this.commandManager = new CommandManager(this);
this.hologramHandler = new HologramHandler(this);
PluginManager pluginManager = getServer().getPluginManager();
// Register Hologram Plugin
if (pluginManager.isPluginEnabled("Arconix"))
hologram = new HologramArconix(this);
// Event registration
pluginManager.registerEvents(new BlockListeners(this), this);
pluginManager.registerEvents(new ChatListeners(this), this);
pluginManager.registerEvents(new EntityListeners(this), this);
pluginManager.registerEvents(new InteractListeners(this), this);
pluginManager.registerEvents(new InventoryListeners(this), this);
this.loadFromFile();
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
console.sendMessage(TextComponent.formatText("&a============================="));
console.sendMessage(Methods.formatText("&a============================="));
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
getServer().getPluginManager().registerEvents(new ChatListeners(this), this);
getServer().getPluginManager().registerEvents(new EntityListeners(this), this);
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
getServer().getPluginManager().registerEvents(new InventoryListeners(this), this);
}
/*
@ -131,10 +134,10 @@ public class UltimateKits extends JavaPlugin {
public void onDisable() {
saveToFile();
kitManager.clearKits();
console.sendMessage(TextComponent.formatText("&a============================="));
console.sendMessage(TextComponent.formatText("&7UltimateKits " + this.getDescription().getVersion() + " by &5Songoda <3!"));
console.sendMessage(TextComponent.formatText("&7Action: &cDisabling&7..."));
console.sendMessage(TextComponent.formatText("&a============================="));
console.sendMessage(Methods.formatText("&a============================="));
console.sendMessage(Methods.formatText("&7UltimateKits " + this.getDescription().getVersion() + " by &5Songoda <3!"));
console.sendMessage(Methods.formatText("&7Action: &cDisabling&7..."));
console.sendMessage(Methods.formatText("&a============================="));
}
/*
@ -168,7 +171,7 @@ public class UltimateKits extends JavaPlugin {
Kit kit = new Kit(kitName, title, link, price, material, delay, hidden, contents, KitAnimation.valueOf(kitAnimation));
kitManager.addKit(kit);
} catch (Exception ex) {
console.sendMessage(TextComponent.formatText("&cYour kit &4" + kitName + " &cis setup incorrectly."));
console.sendMessage(Methods.formatText("&cYour kit &4" + kitName + " &cis setup incorrectly."));
Debugger.runReport(ex);
}
}
@ -178,7 +181,7 @@ public class UltimateKits extends JavaPlugin {
*/
if (dataFile.getConfig().contains("BlockData")) {
for (String key : dataFile.getConfig().getConfigurationSection("BlockData").getKeys(false)) {
Location location = Arconix.pl().getApi().serialize().unserializeLocation(key);
Location location = Methods.unserializeLocation(key);
Kit kit = kitManager.getKit(dataFile.getConfig().getString("BlockData." + key + ".kit"));
KitType type = KitType.valueOf(dataFile.getConfig().getString("BlockData." + key + ".type", "PREVIEW"));
boolean holograms = dataFile.getConfig().getBoolean("BlockData." + key + ".holograms");
@ -247,7 +250,7 @@ public class UltimateKits extends JavaPlugin {
* Save kit locations from KitManager to Configuration.
*/
for (KitBlockData kitBlockData : kitManager.getKitLocations().values()) {
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(kitBlockData.getLocation());
String locationStr = Methods.serializeLocation(kitBlockData.getLocation());
dataFile.getConfig().set("BlockData." + locationStr + ".type", kitBlockData.getType().name());
dataFile.getConfig().set("BlockData." + locationStr + ".kit", kitBlockData.getKit().getName());
dataFile.getConfig().set("BlockData." + locationStr + ".holograms", kitBlockData.showHologram());
@ -305,7 +308,6 @@ public class UltimateKits extends JavaPlugin {
this.references = new References();
this.setupConfig();
loadFromFile();
hologramHandler.updateHolograms();
} catch (Exception ex) {
Debugger.runReport(ex);
}
@ -356,10 +358,10 @@ public class UltimateKits extends JavaPlugin {
return commandManager;
}
public HologramHandler getHologramHandler() {
return hologramHandler;
public Hologram getHologram() {
return hologram;
}
/**
* Grab instance of the item serializer
*

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatekits.command;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.commands.*;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -60,7 +60,7 @@ public class CommandManager implements CommandExecutor {
}
}
}
commandSender.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText("&7The command you entered does not exist or is spelt incorrectly."));
commandSender.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&7The command you entered does not exist or is spelt incorrectly."));
return true;
}
@ -72,8 +72,8 @@ public class CommandManager implements CommandExecutor {
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
AbstractCommand.ReturnType returnType = command.runCommand(plugin, sender, strings);
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
sender.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText("&cInvalid Syntax!"));
sender.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
sender.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&cInvalid Syntax!"));
sender.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
}
return;
}

View File

@ -1,11 +1,11 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.gui.GUIKitEditor;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -25,7 +25,7 @@ public class CommandCreatekit extends AbstractCommand {
return ReturnType.FAILURE;
}
player.sendMessage(UltimateKits.getInstance().getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&aThat kit doesn't exist. Creating it now."));
player.sendMessage(UltimateKits.getInstance().getReferences().getPrefix() + Methods.formatText("&aThat kit doesn't exist. Creating it now."));
Kit kit = new Kit(kitStr.trim());
UltimateKits.getInstance().getKitManager().addKit(kit);
new GUIKitEditor(instance, player, kit, null, null, 0);

View File

@ -1,11 +1,11 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.gui.GUIBlockEditor;
import com.songoda.ultimatekits.gui.GUIKitEditor;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -20,12 +20,12 @@ public class CommandEdit extends AbstractCommand {
protected ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
Player player = (Player) sender;
Block block = player.getTargetBlock(null, 200);
String loc = Arconix.pl().getApi().serialize().serializeLocation(block);
String loc = Methods.serializeLocation(block);
if (args.length > 2) return ReturnType.SYNTAX_ERROR;
if (args.length == 1) {
if (instance.getConfig().getString("data.block." + loc) == null) {
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8This block does not contain a kit."));
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&8This block does not contain a kit."));
return ReturnType.FAILURE;
}
new GUIBlockEditor(instance, player, block.getLocation());

View File

@ -1,11 +1,11 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.key.Key;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -27,25 +27,25 @@ public class CommandKey extends AbstractCommand {
return ReturnType.FAILURE;
}
if (Bukkit.getPlayer(args[3]) == null && !args[3].trim().equalsIgnoreCase("all")) {
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is offline!"));
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&cThat username does not exist, or the user is offline!"));
return ReturnType.FAILURE;
}
int amt = 1;
if (args.length == 5) {
if (!Arconix.pl().getApi().doMath().isNumeric(args[4])) {
if (!Methods.isNumeric(args[4])) {
amt = 0;
} else {
amt = Integer.parseInt(args[4]);
}
}
if (amt == 0) {
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&a" + args[3] + " &cis not a number."));
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&a" + args[3] + " &cis not a number."));
return ReturnType.FAILURE;
}
Key key = instance.getKeyManager().getKey(args[2]);
if (key == null) {
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&a" + args[3] + " &cis not a key."));
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&a" + args[3] + " &cis not a key."));
return ReturnType.FAILURE;
}

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
@ -66,10 +65,10 @@ public class CommandKit extends AbstractCommand {
}
Kit kit = instance.getKitManager().getKit(kitName);
kit.give(player2, false, false, true);
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&7You gave &9" + player2.getDisplayName() + "&7 kit &9" + kit.getShowableName() + "&7."));
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&7You gave &9" + player2.getDisplayName() + "&7 kit &9" + kit.getShowableName() + "&7."));
return ReturnType.SUCCESS;
}
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.SYNTAX.getConfigValue()));
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText(Lang.SYNTAX.getConfigValue()));
return ReturnType.SUCCESS;
}

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.command.CommandSender;
public class CommandReload extends AbstractCommand {
@ -14,7 +14,7 @@ public class CommandReload extends AbstractCommand {
@Override
protected ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
instance.reload();
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&7Configuration and Language files reloaded."));
sender.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&7Configuration and Language files reloaded."));
return ReturnType.SUCCESS;
}

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -25,8 +25,8 @@ public class CommandRemove extends AbstractCommand {
Block block = player.getTargetBlock(null, 200);
Kit kit = instance.getKitManager().removeKitFromLocation(block.getLocation());
if (kit == null) return ReturnType.FAILURE;
UltimateKits.getInstance().getHologramHandler().updateHolograms();
player.sendMessage(Arconix.pl().getApi().format().formatText(UltimateKits.getInstance().getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType().toString() + "&8."));
instance.getHologram().remove(kit);
player.sendMessage(Methods.formatText(UltimateKits.getInstance().getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType().toString() + "&8."));
return ReturnType.SUCCESS;
}

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -28,7 +28,7 @@ public class CommandSet extends AbstractCommand {
}
Block b = player.getTargetBlock(null, 200);
instance.getKitManager().addKitToLocation(instance.getKitManager().getKit(kit), b.getLocation());
sender.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Kit &a" + kit + " &8set to: &a" + b.getType().toString() + "&8."));
sender.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&8Kit &a" + kit + " &8set to: &a" + b.getType().toString() + "&8."));
return ReturnType.SUCCESS;
}

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatekits.command.commands;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.command.AbstractCommand;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.command.CommandSender;
public class CommandUltimateKits extends AbstractCommand {
@ -14,11 +14,11 @@ public class CommandUltimateKits extends AbstractCommand {
@Override
protected AbstractCommand.ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
sender.sendMessage("");
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna"));
sender.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna"));
for (AbstractCommand command : instance.getCommandManager().getCommands()) {
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
sender.sendMessage(TextComponent.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
}
}
sender.sendMessage("");

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatekits.events;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -31,8 +31,8 @@ public class BlockListeners implements Listener {
if (kitBlockData == null) return;
Kit kit = kitBlockData.getKit();
instance.getKitManager().removeKitFromLocation(block.getLocation());
instance.getHologramHandler().updateHolograms();
event.getPlayer().sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8."));
instance.getHologram().remove(kitBlockData);
event.getPlayer().sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8."));
} catch (Exception e) {
Debugger.runReport(e);

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.events;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.gui.GUIBlockEditor;
@ -8,6 +7,7 @@ import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.kit.KitType;
import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -58,7 +58,7 @@ public class InteractListeners implements Listener {
if (kitBlockData.getType() != KitType.PREVIEW) {
if (kitBlockData.getType() == KitType.CRATE) {
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + Lang.NOT_KEY.getConfigValue()));
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + Lang.NOT_KEY.getConfigValue()));
} else if (kitBlockData.getType() == KitType.CLAIM) {
if (!player.hasPermission("essentials.kit." + kit.getName().toLowerCase()) || !player.hasPermission("ultimatekits.kit." + kit.getName().toLowerCase())) {
player.sendMessage(instance.getReferences().getPrefix() + Lang.NO_PERM.getConfigValue());
@ -69,7 +69,7 @@ public class InteractListeners implements Listener {
kit.updateDelay(player);
} else {
long time = kit.getNextUse(player);
player.sendMessage(instance.getReferences().getPrefix() + Lang.NOT_YET.getConfigValue(Arconix.pl().getApi().format().readableTime(time)));
player.sendMessage(instance.getReferences().getPrefix() + Lang.NOT_YET.getConfigValue(Methods.makeReadable(time)));
}
}
} else if (kit.getLink() != null || kit.getPrice() != 0) {

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.KitBlockData;
@ -49,21 +48,21 @@ public class GUIBlockEditor extends AbstractGUI {
Lang.EXIT.getConfigValue());
ArrayList<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&7Click to swap this kit blocks function."));
lore.add(Methods.formatText("&7Click to swap this kit blocks function."));
lore.add("");
if (kitBlockData.getType() == KitType.PREVIEW) {
lore.add(Arconix.pl().getApi().format().formatText("&6Preview"));
lore.add(Arconix.pl().getApi().format().formatText("&7Crate"));
lore.add(Arconix.pl().getApi().format().formatText("&7Claim"));
lore.add(Methods.formatText("&6Preview"));
lore.add(Methods.formatText("&7Crate"));
lore.add(Methods.formatText("&7Claim"));
} else if (kitBlockData.getType() == KitType.CRATE) {
lore.add(Arconix.pl().getApi().format().formatText("&7Preview"));
lore.add(Arconix.pl().getApi().format().formatText("&6Crate"));
lore.add(Arconix.pl().getApi().format().formatText("&7Claim"));
lore.add(Methods.formatText("&7Preview"));
lore.add(Methods.formatText("&6Crate"));
lore.add(Methods.formatText("&7Claim"));
} else if (kitBlockData.getType() == KitType.CLAIM) {
lore.add(Arconix.pl().getApi().format().formatText("&7Preview"));
lore.add(Arconix.pl().getApi().format().formatText("&7Crate"));
lore.add(Arconix.pl().getApi().format().formatText("&6Claim"));
lore.add(Methods.formatText("&7Preview"));
lore.add(Methods.formatText("&7Crate"));
lore.add(Methods.formatText("&6Claim"));
}
createButton(11, Material.COMPARATOR, "&5&lSwitch kit type", lore);
@ -89,7 +88,7 @@ public class GUIBlockEditor extends AbstractGUI {
else if (kitBlockData.getType() == KitType.CLAIM) kitBlockData.setType(KitType.PREVIEW);
instance.saveConfig();
instance.getHologramHandler().updateHolograms();
instance.getHologram().update(kitBlockData);
constructGUI();
});
registerClickable(13, (player, inventory, cursor, slot, type) -> {

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -35,13 +34,13 @@ public class GUIConfirmBuy extends AbstractGUI {
cost = 0;
}
String title = Arconix.pl().getApi().format().formatTitle("&c" + StringUtils.capitalize(kit.getName().toLowerCase()));
String title = Methods.formatTitle("&c" + StringUtils.capitalize(kit.getName().toLowerCase()));
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
if (kit.getDisplayItem() != null) item = new ItemStack(kit.getDisplayItem());
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(title);
ArrayList<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&a$" + Arconix.pl().getApi().format().formatEconomy(cost)));
lore.add(Methods.formatText("&a$" + Methods.formatEconomy(cost)));
int nu = 0;
while (nu != 27) {
@ -89,7 +88,7 @@ public class GUIConfirmBuy extends AbstractGUI {
}));
registerClickable(15, ((player1, inventory1, cursor, slot, type) -> {
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + Lang.BUYCANCELLED.getConfigValue()));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + Lang.BUYCANCELLED.getConfigValue()));
player.closeInventory();
}));
}

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -51,34 +50,34 @@ public class GUIDecorOptions extends AbstractGUI {
Lang.EXIT.getConfigValue());
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
ItemStack back = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
inventory.setItem(0, back);
createButton(0, back, Lang.BACK.getConfigValue());
ArrayList<String> lore = new ArrayList<>();
if (kitBlockData.showHologram()) {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &aEnabled&7."));
lore.add(Methods.formatText("&7Currently: &aEnabled&7."));
} else {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently &cDisabled&7."));
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
}
createButton(10, Material.SIGN, "&9&lToggle Holograms", lore);
lore = new ArrayList<>();
if (kitBlockData.hasParticles()) {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &aEnabled&7."));
lore.add(Methods.formatText("&7Currently: &aEnabled&7."));
} else {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently &cDisabled&7."));
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
}
createButton(12, Material.POTION, "&9&lToggle Particles", lore);
lore = new ArrayList<>();
if (kitBlockData.isDisplayingItems()) {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &aEnabled&7."));
lore.add(Methods.formatText("&7Currently: &aEnabled&7."));
} else {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently &cDisabled&7."));
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
}
createButton(14, Material.DIAMOND, "&9&lToggle DisplayItems", lore);
@ -90,16 +89,16 @@ public class GUIDecorOptions extends AbstractGUI {
lore = new ArrayList<>();
if (kitBlockData.isItemOverride()) {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &aEnabled&7."));
lore.add(Methods.formatText("&7Currently: &aEnabled&7."));
} else {
lore.add(Arconix.pl().getApi().format().formatText("&7Currently &cDisabled&7."));
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
}
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText("&7Enabling this option will "));
lore.add(Arconix.pl().getApi().format().formatText("&7override the DisplayItems"));
lore.add(Arconix.pl().getApi().format().formatText("&7above your kit to the single"));
lore.add(Arconix.pl().getApi().format().formatText("&7DisplayItem set in this kit"));
lore.add(Arconix.pl().getApi().format().formatText("&7GUI options."));
lore.add(Methods.formatText("&7Enabling this option will "));
lore.add(Methods.formatText("&7override the DisplayItems"));
lore.add(Methods.formatText("&7above your kit to the single"));
lore.add(Methods.formatText("&7DisplayItem set in this kit"));
lore.add(Methods.formatText("&7GUI options."));
createButton(16, material, "&9&lToggle DisplayItem Override", lore);
}
@ -115,7 +114,7 @@ public class GUIDecorOptions extends AbstractGUI {
} else {
kitBlockData.setShowHologram(true);
}
UltimateKits.getInstance().getHologramHandler().updateHolograms();
UltimateKits.getInstance().getHologram().update(kitBlockData);
constructGUI();
});
@ -132,8 +131,7 @@ public class GUIDecorOptions extends AbstractGUI {
boolean isHolo = kitBlockData.showHologram();
if (isHolo) {
kitBlockData.setShowHologram(false);
UltimateKits.getInstance().getHologramHandler().updateHolograms();
UltimateKits.getInstance().getHologram().remove(kitBlockData);
}
if (kitBlockData.isDisplayingItems()) {
kitBlockData.setDisplayingItems(false);
@ -141,8 +139,7 @@ public class GUIDecorOptions extends AbstractGUI {
kitBlockData.setDisplayingItems(true);
}
if (isHolo) {
kitBlockData.setShowHologram(true);
UltimateKits.getInstance().getHologramHandler().updateHolograms();
UltimateKits.getInstance().getHologram().add(kitBlockData);
}
constructGUI();
});

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -35,9 +34,9 @@ public class GUIDisplayKit extends AbstractGUI {
this.plugin = plugin;
this.back = back;
String guititle = Arconix.pl().getApi().format().formatTitle(Lang.PREVIEW_TITLE.getConfigValue(kit.getShowableName()));
String guititle = Methods.formatTitle(Lang.PREVIEW_TITLE.getConfigValue(kit.getShowableName()));
if (kit.getTitle() != null) {
guititle = Lang.PREVIEW_TITLE.getConfigValue(Arconix.pl().getApi().format().formatText(kit.getTitle(), true));
guititle = Lang.PREVIEW_TITLE.getConfigValue(Methods.formatText(kit.getTitle(), true));
}
list = kit.getReadableContents(player, true, true, false);
@ -133,19 +132,19 @@ public class GUIDisplayKit extends AbstractGUI {
lore.add(Lang.CLICKECO.getConfigValue("0"));
if (player.isOp()) {
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText("&7This is free because"));
lore.add(Arconix.pl().getApi().format().formatText("&7you have perms for it."));
lore.add(Arconix.pl().getApi().format().formatText("&7Everyone else buys"));
lore.add(Arconix.pl().getApi().format().formatText("&7this for &a$" + Arconix.pl().getApi().format().formatEconomy(kit.getPrice()) + "&7."));
lore.add(Methods.formatText("&7This is free because"));
lore.add(Methods.formatText("&7you have perms for it."));
lore.add(Methods.formatText("&7Everyone else buys"));
lore.add(Methods.formatText("&7this for &a$" + Methods.formatEconomy(kit.getPrice()) + "&7."));
}
} else {
lore.add(Lang.CLICKECO.getConfigValue(Arconix.pl().getApi().format().formatEconomy(kit.getPrice())));
lore.add(Lang.CLICKECO.getConfigValue(Methods.formatEconomy(kit.getPrice())));
}
if (kit.getDelay() != 0 && player.isOp()) {
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText("&7You do not have a delay"));
lore.add(Arconix.pl().getApi().format().formatText("&7because you have perms"));
lore.add(Arconix.pl().getApi().format().formatText("&7to bypass the delay."));
lore.add(Methods.formatText("&7You do not have a delay"));
lore.add(Methods.formatText("&7because you have perms"));
lore.add(Methods.formatText("&7to bypass the delay."));
}
linkmeta.setLore(lore);
link.setItemMeta(linkmeta);
@ -203,7 +202,7 @@ public class GUIDisplayKit extends AbstractGUI {
if (back != null && !plugin.getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack skull2 = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
ItemStack skull2 = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) skull2.getItemMeta();
skull2.setDurability((short) 3);
skull2Meta.setDisplayName(Lang.BACK.getConfigValue());

View File

@ -1,7 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -58,7 +56,7 @@ public class GUIGUIOptions extends AbstractGUI {
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack back = head2;
back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
back = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
back.setDurability((short) 3);
skull2Meta.setDisplayName(Lang.BACK.getConfigValue());
@ -68,45 +66,45 @@ public class GUIGUIOptions extends AbstractGUI {
ArrayList<String> lore = new ArrayList<>();
if (kit.getTitle() != null)
lore.add(TextComponent.formatText("&7Currently: &a" + kit.getTitle() + "&7."));
lore.add(Methods.formatText("&7Currently: &a" + kit.getTitle() + "&7."));
else
lore.add(TextComponent.formatText("&7Currently: &cNot set&7."));
lore.add(TextComponent.formatText(""));
lore.add(TextComponent.formatText("&7Left-Click: &9to set"));
lore.add(TextComponent.formatText("&9the kit title for holograms"));
lore.add(TextComponent.formatText("&9and the kit / kit GUIs."));
lore.add(TextComponent.formatText(""));
lore.add(TextComponent.formatText("&7Right-Click: &9to reset."));
lore.add(Methods.formatText("&7Currently: &cNot set&7."));
lore.add(Methods.formatText(""));
lore.add(Methods.formatText("&7Left-Click: &9to set"));
lore.add(Methods.formatText("&9the kit title for holograms"));
lore.add(Methods.formatText("&9and the kit / kit GUIs."));
lore.add(Methods.formatText(""));
lore.add(Methods.formatText("&7Right-Click: &9to reset."));
createButton(11, Material.NAME_TAG, "&9&lSet Title", lore);
lore = new ArrayList<>();
if (kit.getDisplayItem() != null) {
lore.add(TextComponent.formatText("&7Currently set to: &a" + kit.getDisplayItem().toString() + "&7."));
lore.add(Methods.formatText("&7Currently set to: &a" + kit.getDisplayItem().toString() + "&7."));
} else {
lore.add(TextComponent.formatText("&7Currently &cDisabled&7."));
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
}
lore.add("");
lore.add(TextComponent.formatText("&7Left-Click to: &9Set a"));
lore.add(TextComponent.formatText("&9display item for this kit"));
lore.add(TextComponent.formatText("&9to the item in your hand."));
lore.add(Methods.formatText("&7Left-Click to: &9Set a"));
lore.add(Methods.formatText("&9display item for this kit"));
lore.add(Methods.formatText("&9to the item in your hand."));
lore.add("");
lore.add(TextComponent.formatText("&7Right-Click to: &9Remove the item."));
lore.add(Methods.formatText("&7Right-Click to: &9Remove the item."));
createButton(13, Material.BEACON, "&9&lSet DisplayItem", lore);
lore = new ArrayList<>();
if (kit.isHidden()) {
lore.add(TextComponent.formatText("&7Currently: &cHidden&7."));
lore.add(Methods.formatText("&7Currently: &cHidden&7."));
} else {
lore.add(TextComponent.formatText("&7Currently: &aVisible&7."));
lore.add(Methods.formatText("&7Currently: &aVisible&7."));
}
lore.add("");
lore.add(TextComponent.formatText("&7A hidden kit will not"));
lore.add(TextComponent.formatText("&7show up in the /kit gui."));
lore.add(TextComponent.formatText("&7This is usually optimal for"));
lore.add(TextComponent.formatText("&7preventing players from seeing"));
lore.add(TextComponent.formatText("&7non obtainable kit or starter kit."));
lore.add(Methods.formatText("&7A hidden kit will not"));
lore.add(Methods.formatText("&7show up in the /kit gui."));
lore.add(Methods.formatText("&7This is usually optimal for"));
lore.add(Methods.formatText("&7preventing players from seeing"));
lore.add(Methods.formatText("&7non obtainable kit or starter kit."));
createButton(15, Material.COAL, "&9&lHide kit", lore);
}
@ -123,8 +121,8 @@ public class GUIGUIOptions extends AbstractGUI {
String msg = event.getName();
kit.setTitle(msg);
plugin.saveConfig();
player.sendMessage(TextComponent.formatText(plugin.getReferences().getPrefix() + "&8Title &5" + msg + "&8 added to Kit &a" + kit.getShowableName() + "&8."));
plugin.getHologramHandler().updateHolograms();
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Title &5" + msg + "&8 added to Kit &a" + kit.getShowableName() + "&8."));
plugin.getHologram().update(kit);
});
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
@ -138,7 +136,7 @@ public class GUIGUIOptions extends AbstractGUI {
gui.open();
} else {
kit.setTitle("");
plugin.getHologramHandler().updateHolograms();
plugin.getHologram().update(kit);
constructGUI();
}
}));
@ -147,14 +145,14 @@ public class GUIGUIOptions extends AbstractGUI {
if (type.isLeftClick()) {
ItemStack is = player.getItemInHand();
if (is == null || is.getType() == Material.AIR) {
player.sendMessage(TextComponent.formatText(plugin.getReferences().getPrefix() + "&8You must be holding an item to use this function."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8You must be holding an item to use this function."));
return;
}
kit.setDisplayItem(is.getType());
player.sendMessage(TextComponent.formatText(plugin.getReferences().getPrefix() + "&8Custom Item Display set for kit &a" + kit.getShowableName() + "&8."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Custom Item Display set for kit &a" + kit.getShowableName() + "&8."));
} else {
kit.setDisplayItem(null);
player.sendMessage(TextComponent.formatText(plugin.getReferences().getPrefix() + "&8Custom Item Display removed from kit &a" + kit.getShowableName() + "&8."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Custom Item Display removed from kit &a" + kit.getShowableName() + "&8."));
}
constructGUI();
}));

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -56,7 +55,7 @@ public class GUIGeneralOptions extends AbstractGUI {
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack back = head2;
back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
back = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
back.setDurability((short) 3);
skull2Meta.setDisplayName(Lang.BACK.getConfigValue());
@ -90,10 +89,10 @@ public class GUIGeneralOptions extends AbstractGUI {
if (msg.trim().equalsIgnoreCase(kit.getName())) {
plugin.getKitManager().removeKit(kit);
plugin.getHologramHandler().updateHolograms();
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&cKit destroyed successfully."));
plugin.getHologram().update(kit);
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&cKit destroyed successfully."));
} else {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&cKit was not Destroyed."));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&cKit was not Destroyed."));
}
});
@ -118,8 +117,8 @@ public class GUIGeneralOptions extends AbstractGUI {
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
String msg = event.getName();
if (!Arconix.pl().getApi().doMath().isNumeric(msg)) {
player.sendMessage(Arconix.pl().getApi().format().formatText("&a" + msg + " &8is not a number. Please do not include a &a$&8."));
if (!Methods.isNumeric(msg)) {
player.sendMessage(Methods.formatText("&a" + msg + " &8is not a number. Please do not include a &a$&8."));
} else {
kit.setDelay(Integer.parseInt(msg));
}

View File

@ -1,7 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -71,7 +69,7 @@ public class GUIKitEditor extends AbstractGUI {
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack back;
back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
back = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
back.setDurability((short) 3);
skull2Meta.setDisplayName(Lang.BACK.getConfigValue());
@ -79,16 +77,16 @@ public class GUIKitEditor extends AbstractGUI {
ItemStack it = new ItemStack(Material.CHEST, 1);
ItemMeta itmeta = it.getItemMeta();
itmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&5&l" + kit.getName()));
itmeta.setDisplayName(Methods.formatText("&5&l" + kit.getName()));
ArrayList<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&fPermissions:"));
lore.add(Arconix.pl().getApi().format().formatText("&7ultimatekits.kit." + kit.getName().toLowerCase()));
lore.add(Methods.formatText("&fPermissions:"));
lore.add(Methods.formatText("&7ultimatekits.kit." + kit.getName().toLowerCase()));
itmeta.setLore(lore);
it.setItemMeta(itmeta);
ItemStack glass = new ItemStack(Material.GRAY_STAINED_GLASS_PANE, 1);
ItemMeta glassmeta = glass.getItemMeta();
glassmeta.setDisplayName(Arconix.pl().getApi().format().formatText("&" + kit.getName().replaceAll(".(?!$)", "$0&")));
glassmeta.setDisplayName(Methods.formatText("&" + kit.getName().replaceAll(".(?!$)", "$0&")));
glass.setItemMeta(glassmeta);
if (this.back != null)
@ -118,26 +116,26 @@ public class GUIKitEditor extends AbstractGUI {
if (meta.hasLore()) itemLore = meta.getLore();
else itemLore = new ArrayList<>();
itemLore.add(TextComponent.convertToInvisibleString("----"));
itemLore.add(TextComponent.formatText("&7" + Lang.CHANCE.getConfigValue() + ": &6" + item.getChance() + "%"));
itemLore.add(Methods.convertToInvisibleString("----"));
itemLore.add(Methods.formatText("&7" + Lang.CHANCE.getConfigValue() + ": &6" + item.getChance() + "%"));
if (isInFuction) {
itemLore.add(TextComponent.formatText("&7Display Item: &6" + (item.getDisplayItem() == null ? "null" : item.getDisplayItem().name())));
itemLore.add(TextComponent.formatText("&7Display Name: &6" + TextComponent.formatText(item.getDisplayName())));
itemLore.add(TextComponent.formatText("&7Display Lore: &6" + TextComponent.formatText(item.getDisplayLore())));
itemLore.add(Methods.formatText("&7Display Item: &6" + (item.getDisplayItem() == null ? "null" : item.getDisplayItem().name())));
itemLore.add(Methods.formatText("&7Display Name: &6" + Methods.formatText(item.getDisplayName())));
itemLore.add(Methods.formatText("&7Display Lore: &6" + Methods.formatText(item.getDisplayLore())));
}
itemLore.add("");
if (isInFuction) {
itemLore.add(TextComponent.formatText("&7Left-Click: &6To set a display item."));
itemLore.add(TextComponent.formatText("&7Middle-Click: &6To set a display name."));
itemLore.add(TextComponent.formatText("&7Right-Click: &6To set display lore."));
itemLore.add(TextComponent.formatText("&7Shift-Click: &6To set chance."));
itemLore.add(Methods.formatText("&7Left-Click: &6To set a display item."));
itemLore.add(Methods.formatText("&7Middle-Click: &6To set a display name."));
itemLore.add(Methods.formatText("&7Right-Click: &6To set display lore."));
itemLore.add(Methods.formatText("&7Shift-Click: &6To set chance."));
itemLore.add("");
itemLore.add(TextComponent.formatText("&7Display options only show up on display."));
itemLore.add(TextComponent.formatText("&7This can be useful if you want to explain"));
itemLore.add(TextComponent.formatText("&7What an item does without putting it in the"));
itemLore.add(TextComponent.formatText("&7permanent lore."));
itemLore.add(Methods.formatText("&7Display options only show up on display."));
itemLore.add(Methods.formatText("&7This can be useful if you want to explain"));
itemLore.add(Methods.formatText("&7What an item does without putting it in the"));
itemLore.add(Methods.formatText("&7permanent lore."));
itemLore.add("");
itemLore.add(TextComponent.formatText("&6Leave function mode to move items."));
itemLore.add(Methods.formatText("&6Leave function mode to move items."));
}
meta.setLore(itemLore);
is.setItemMeta(meta);
@ -279,7 +277,7 @@ public class GUIKitEditor extends AbstractGUI {
kit.saveKit(Arrays.asList(items));
if (!muteSave)
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8Changes to &a" + kit.getShowableName() + " &8saved successfully."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Changes to &a" + kit.getShowableName() + " &8saved successfully."));
muteSave = false;
}
@ -288,7 +286,7 @@ public class GUIKitEditor extends AbstractGUI {
ItemMeta meta = itemStack.getItemMeta();
List<String> newLore = new ArrayList<>();
for (String line : meta.getLore()) {
if (line.equals(TextComponent.convertToInvisibleString("----"))) break;
if (line.equals(Methods.convertToInvisibleString("----"))) break;
newLore.add(line);
}
meta.setLore(newLore);
@ -319,7 +317,7 @@ public class GUIKitEditor extends AbstractGUI {
toReplace = item2.getMoveableItem();
} catch (Exception e) {
player.sendMessage(Arconix.pl().getApi().format().formatText("&a" + msg + " &8is not a valid material."));
player.sendMessage(Methods.formatText("&a" + msg + " &8is not a valid material."));
}
this.slot = slot;
this.toReplace = toReplace;
@ -427,7 +425,7 @@ public class GUIKitEditor extends AbstractGUI {
meta2.setDisplayName(Lang.MONEY.getConfigValue());
parseStack2.setItemMeta(meta2);
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8Money &5$" + msg + "&8 has been added to your kit."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Money &5$" + msg + "&8 has been added to your kit."));
this.slot = 0;
this.toReplace = parseStack2;
@ -463,7 +461,7 @@ public class GUIKitEditor extends AbstractGUI {
meta.setDisplayName(Lang.COMMAND.getConfigValue());
parseStack.setItemMeta(meta);
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8Command &5" + msg + "&8 has been added to your kit."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Command &5" + msg + "&8 has been added to your kit."));
this.slot = 0;
this.toReplace = parseStack;

View File

@ -1,7 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -141,18 +139,18 @@ public class GUIKitSelector extends AbstractGUI {
Kit kit = plugin.getKitManager().getKit(kitItem);
String title = Lang.GUI_KIT_NAME.getConfigValue(Arconix.pl().getApi().format().formatText(kitItem, true));
String title = Lang.GUI_KIT_NAME.getConfigValue(Methods.formatText(kitItem, true));
if (kit.getTitle() != null)
title = Arconix.pl().getApi().format().formatText(kit.getTitle());
title = Methods.formatText(kit.getTitle());
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
if (kit.getDisplayItem() != null)
item.setType(kit.getDisplayItem());
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(TextComponent.convertToInvisibleString(kitItem + ":") + Arconix.pl().getApi().format().formatText(title));
meta.setDisplayName(Methods.convertToInvisibleString(kitItem + ":") + Methods.formatText(title));
ArrayList<String> lore = new ArrayList<>();
if (kit.getPrice() != 0)
lore.add(Arconix.pl().getApi().format().formatText("&7This kit costs &a$" + kit.getPrice() + "&7."));
lore.add(Methods.formatText("&7This kit costs &a$" + kit.getPrice() + "&7."));
else if (kit.getLink() != null)
lore.add(Lang.LINK.getConfigValue());
@ -162,41 +160,41 @@ public class GUIKitSelector extends AbstractGUI {
String[] parts = Lang.ABOUT_KIT.getConfigValue().split("\\|");
lore.add("");
for (String line : parts)
lore.add(Arconix.pl().getApi().format().formatText(line));
lore.add(Methods.formatText(line));
}
if (kit.hasPermission(player)) {
if (kit.getNextUse(player) == -1) {
lore.add(Arconix.pl().getApi().format().formatText(Lang.ONCE.getConfigValue()));
lore.add(Methods.formatText(Lang.ONCE.getConfigValue()));
} else if (kit.getNextUse(player) > 0) {
if (!Lang.PLEASE_WAIT.getConfigValue().trim().equals("")) {
lore.add(Arconix.pl().getApi().format().formatText(Lang.PLEASE_WAIT.getConfigValue(Arconix.pl().getApi().format().readableTime(kit.getNextUse(player)))));
lore.add(Methods.formatText(Lang.PLEASE_WAIT.getConfigValue(Methods.makeReadable(kit.getNextUse(player)))));
}
} else if (!Lang.READY.getConfigValue().trim().equals("")) {
lore.add(Arconix.pl().getApi().format().formatText(Lang.READY.getConfigValue()));
lore.add(Methods.formatText(Lang.READY.getConfigValue()));
}
} else
lore.add(Arconix.pl().getApi().format().formatText(Lang.NO_ACCESS.getConfigValue()));
lore.add(Methods.formatText(Lang.NO_ACCESS.getConfigValue()));
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText(Lang.LEFT_PREVIEW.getConfigValue()));
lore.add(Methods.formatText(Lang.LEFT_PREVIEW.getConfigValue()));
if (kit.hasPermission(player)) {
lore.add(Arconix.pl().getApi().format().formatText(Lang.RIGHT_CLAIM.getConfigValue()));
lore.add(Methods.formatText(Lang.RIGHT_CLAIM.getConfigValue()));
} else if (kit.getPrice() != 0 || kit.getLink() != null) {
lore.add(Arconix.pl().getApi().format().formatText(Lang.RIGHT_BUY.getConfigValue()));
lore.add(Methods.formatText(Lang.RIGHT_BUY.getConfigValue()));
}
if (player.hasPermission("ultimatekits.admin")) {
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText("&6Middle Click &7to edit positioning."));
lore.add(Methods.formatText("&6Middle Click &7to edit positioning."));
}
} else {
lore.add(Arconix.pl().getApi().format().formatText("&6&lEdit Mode"));
lore.add(Methods.formatText("&6&lEdit Mode"));
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText("&6Left Click &7to move kit left"));
lore.add(Arconix.pl().getApi().format().formatText("&6Right Click &7to move kit right"));
lore.add(Methods.formatText("&6Left Click &7to move kit left"));
lore.add(Methods.formatText("&6Right Click &7to move kit right"));
lore.add("");
lore.add(Arconix.pl().getApi().format().formatText("&6Middle Click &7to go back."));
lore.add(Methods.formatText("&6Middle Click &7to go back."));
}
meta.setLore(lore);
item.setItemMeta(meta);
@ -211,23 +209,23 @@ public class GUIKitSelector extends AbstractGUI {
boolean hit = false;
for (String line : parts) {
if (!hit)
infometa.setDisplayName(Arconix.pl().getApi().format().formatText(line));
infometa.setDisplayName(Methods.formatText(line));
else
lore.add(Arconix.pl().getApi().format().formatText(line));
lore.add(Methods.formatText(line));
hit = true;
}
infometa.setLore(lore);
info.setItemMeta(infometa);
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack skull = Arconix.pl().getApi().getGUI().addTexture(head, "http://textures.minecraft.net/texture/1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b");
ItemStack skull = Methods.addTexture(head, "http://textures.minecraft.net/texture/1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b");
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
skull.setDurability((short) 3);
skullMeta.setDisplayName(Lang.NEXT.getConfigValue());
skull.setItemMeta(skullMeta);
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack skull2 = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
ItemStack skull2 = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) skull2.getItemMeta();
skull2.setDurability((short) 3);
skull2Meta.setDisplayName(Lang.LAST.getConfigValue());

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatekits.gui;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
@ -57,7 +56,7 @@ public class GUISellingOptions extends AbstractGUI {
ItemStack head2 = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
ItemStack back = head2;
back = Arconix.pl().getApi().getGUI().addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
back = Methods.addTexture(head2, "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
back.setDurability((short) 3);
skull2Meta.setDisplayName(Lang.BACK.getConfigValue());
@ -68,40 +67,40 @@ public class GUISellingOptions extends AbstractGUI {
ArrayList<String> lore = new ArrayList<>();
if (kit.getPrice() != 0 ||
kit.getLink() != null)
lore.add(Arconix.pl().getApi().format().formatText("&7Currently &aFor Sale&7."));
lore.add(Methods.formatText("&7Currently &aFor Sale&7."));
else
lore.add(Arconix.pl().getApi().format().formatText("&7Currently &cNot For Sale&7."));
lore.add(Arconix.pl().getApi().format().formatText(""));
lore.add(Arconix.pl().getApi().format().formatText("&7Clicking this option will"));
lore.add(Arconix.pl().getApi().format().formatText("&7remove this kit from sale."));
lore.add(Methods.formatText("&7Currently &cNot For Sale&7."));
lore.add(Methods.formatText(""));
lore.add(Methods.formatText("&7Clicking this option will"));
lore.add(Methods.formatText("&7remove this kit from sale."));
createButton(11, Material.BARRIER, "&c&lSet not for sale", lore);
lore = new ArrayList<>();
if (kit.getLink() != null)
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &a" + kit.getLink() + "&7."));
lore.add(Methods.formatText("&7Currently: &a" + kit.getLink() + "&7."));
else
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &cNot set&7."));
lore.add(Arconix.pl().getApi().format().formatText(""));
lore.add(Arconix.pl().getApi().format().formatText("&7Clicking this option will"));
lore.add(Arconix.pl().getApi().format().formatText("&7allow you to set a link"));
lore.add(Arconix.pl().getApi().format().formatText("&7that players will receive"));
lore.add(Arconix.pl().getApi().format().formatText("&7when attempting to purchase"));
lore.add(Arconix.pl().getApi().format().formatText("&7this kit."));
lore.add(Methods.formatText("&7Currently: &cNot set&7."));
lore.add(Methods.formatText(""));
lore.add(Methods.formatText("&7Clicking this option will"));
lore.add(Methods.formatText("&7allow you to set a link"));
lore.add(Methods.formatText("&7that players will receive"));
lore.add(Methods.formatText("&7when attempting to purchase"));
lore.add(Methods.formatText("&7this kit."));
createButton(13, Material.PAPER, "&a&lSet kit link", lore);
lore = new ArrayList<>();
if (kit.getPrice() != 0)
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &a$" + Arconix.pl().getApi().format().formatEconomy(kit.getPrice()) + "&7."));
lore.add(Methods.formatText("&7Currently: &a$" + Methods.formatEconomy(kit.getPrice()) + "&7."));
else
lore.add(Arconix.pl().getApi().format().formatText("&7Currently: &cNot set&7."));
lore.add(Arconix.pl().getApi().format().formatText(""));
lore.add(Arconix.pl().getApi().format().formatText("&7Clicking this option will"));
lore.add(Arconix.pl().getApi().format().formatText("&7allow you to set a price"));
lore.add(Arconix.pl().getApi().format().formatText("&7that players will be able to"));
lore.add(Arconix.pl().getApi().format().formatText("&7purchase this kit for"));
lore.add(Arconix.pl().getApi().format().formatText("&7requires &aVault&7."));
lore.add(Methods.formatText("&7Currently: &cNot set&7."));
lore.add(Methods.formatText(""));
lore.add(Methods.formatText("&7Clicking this option will"));
lore.add(Methods.formatText("&7allow you to set a price"));
lore.add(Methods.formatText("&7that players will be able to"));
lore.add(Methods.formatText("&7purchase this kit for"));
lore.add(Methods.formatText("&7requires &aVault&7."));
createButton(15, Material.SUNFLOWER, "&a&lSet kit price", lore);
}
@ -117,18 +116,18 @@ public class GUISellingOptions extends AbstractGUI {
String msg = event.getName();
if (plugin.getServer().getPluginManager().getPlugin("Vault") == null) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&8You must have &aVault &8installed to utilize economy.."));
} else if (!Arconix.pl().getApi().doMath().isNumeric(msg)) {
player.sendMessage(Arconix.pl().getApi().format().formatText("&a" + msg + " &8is not a number. Please do not include a &a$&8."));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&8You must have &aVault &8installed to utilize economy.."));
} else if (!Methods.isNumeric(msg)) {
player.sendMessage(Methods.formatText("&a" + msg + " &8is not a number. Please do not include a &a$&8."));
} else {
if (kit.getLink() != null) {
kit.setLink(null);
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8LINK has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8LINK has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
}
Double eco = Double.parseDouble(msg);
kit.setPrice(eco);
plugin.getHologramHandler().updateHolograms();
plugin.getHologram().update(kit);
}
});
@ -149,10 +148,10 @@ public class GUISellingOptions extends AbstractGUI {
if (kit.getPrice() != 0) {
kit.setPrice(0);
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8ECO has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8ECO has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
}
kit.setLink(msg);
plugin.getHologramHandler().updateHolograms();
plugin.getHologram().update(kit);
});
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatekits.handlers;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -69,7 +69,7 @@ public class DisplayItemHandler {
}
ItemMeta meta = is.getItemMeta();
is.setAmount(1);
meta.setDisplayName(TextComponent.convertToInvisibleString(Integer.toString(inum)));
meta.setDisplayName(Methods.convertToInvisibleString(Integer.toString(inum)));
is.setItemMeta(meta);
i.setItemStack(is);
i.setPickupDelay(9999);
@ -80,7 +80,7 @@ public class DisplayItemHandler {
ItemStack is = list.get(0);
is.setAmount(1);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(TextComponent.convertToInvisibleString("0"));
meta.setDisplayName(Methods.convertToInvisibleString("0"));
is.setItemMeta(meta);
Item item = location.getWorld().dropItem(location.add(0, 1, 0), list.get(0));
Vector vec = new Vector(0, 0, 0);

View File

@ -1,133 +0,0 @@
package com.songoda.ultimatekits.handlers;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.kit.KitType;
import com.songoda.ultimatekits.utils.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by songoda on 2/24/2017.
*/
public class HologramHandler {
private final UltimateKits instance;
public HologramHandler(UltimateKits instance) {
this.instance = instance;
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(instance, this::updateHolograms, 0L, 5000L);
}
public void updateHolograms() {
try {
Map<Location, KitBlockData> kitBlocks = instance.getKitManager().getKitLocations();
for (KitBlockData kitBlockData : kitBlocks.values()) {
if (kitBlockData.getLocation().getWorld() == null) continue;
KitType kitType = kitBlockData.getType();
List<String> lines = new ArrayList<String>();
List<String> order = instance.getConfig().getStringList("Main.Hologram Layout");
Kit kit = kitBlockData.getKit();
for (String o : order) {
switch (o.toUpperCase()) {
case "{TITLE}":
String title = kit.getTitle();
if (title == null) {
lines.add(Arconix.pl().getApi().format().formatText("&5" + Arconix.pl().getApi().format().formatText(kit.getName(), true)));
} else {
lines.add(Arconix.pl().getApi().format().formatText("&5" + Arconix.pl().getApi().format().formatText(title)));
}
break;
case "{RIGHT-CLICK}":
if (kitType == KitType.CRATE) {
lines.add(Arconix.pl().getApi().format().formatText(Lang.OPEN_CRATE_HOLOGRAM.getConfigValue()));
break;
}
if (kit.getLink() != null) {
lines.add(Arconix.pl().getApi().format().formatText(Lang.BUY_LINK_HOLOGRAM.getConfigValue()));
break;
}
if (kit.getPrice() != 0) {
double cost = kit.getPrice();
if (cost != 0) {
lines.add(Arconix.pl().getApi().format().formatText(Lang.BUY_ECO_HOLOGRAM.getConfigValue(Arconix.pl().getApi().format().formatEconomy(cost))));
} else {
lines.add(Lang.BUY_ECO_HOLOGRAM.getConfigValue(Arconix.pl().getApi().format().formatText(Lang.FREE.getConfigValue())));
}
}
break;
case "{LEFT-CLICK}":
if (kitType == KitType.CLAIM) {
lines.add(Arconix.pl().getApi().format().formatText(Lang.DAILY_HOLOGRAM.getConfigValue(kit)));
break;
}
if (kit.getLink() == null && kit.getPrice() == 0) {
lines.add(Arconix.pl().getApi().format().formatText(Lang.PREVIEW_ONLY_HOLOGRAM.getConfigValue(kit)));
} else {
lines.add(Arconix.pl().getApi().format().formatText(Lang.PREVIEW_HOLOGRAM.getConfigValue(kit)));
}
break;
default:
lines.add(Arconix.pl().getApi().format().formatText(o));
break;
}
}
double multi = .25 * lines.size();
Location location = kitBlockData.getLocation();
location.add(.5, .75, .5);
Block b = location.getBlock();
if (kitBlockData.isDisplayingItems()) multi += .40;
if (b.getType() == Material.TRAPPED_CHEST
|| b.getType() == Material.CHEST
|| b.getType() == Material.SIGN
|| b.getType() == Material.ENDER_CHEST) multi -= .15;
location.add(0, multi, 0);
remove(location);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, () -> {
if (kitBlockData.showHologram()) {
remove(location);
Arconix.pl().getApi().packetLibrary.getHologramManager().spawnHolograms(location, lines);
}
}, 5L);
}
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void remove(Location location) {
for (Entity e : location.getWorld().getNearbyEntities(location, 1, 50, 1)) {
if (e.getType().equals(EntityType.ARMOR_STAND))
Arconix.pl().getApi().packetLibrary.getHologramManager().despawnHologram(e.getLocation());
}
}
}

View File

@ -0,0 +1,171 @@
package com.songoda.ultimatekits.hologram;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitBlockData;
import com.songoda.ultimatekits.kit.KitType;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public abstract class Hologram {
protected final UltimateKits instance;
Hologram(UltimateKits instance) {
this.instance = instance;
}
public void loadHolograms() {
Collection<KitBlockData> kitBlocks = instance.getKitManager().getKitLocations().values();
if (kitBlocks.size() == 0) return;
for (KitBlockData data : kitBlocks) {
if (data.getWorld() == null) continue;
add(data);
}
}
public void unloadHolograms() {
Collection<KitBlockData> kitBlocks = instance.getKitManager().getKitLocations().values();
if (kitBlocks.size() == 0) return;
for (KitBlockData data : kitBlocks) {
if (data.getWorld() == null) continue;
remove(data);
}
}
public void add(KitBlockData data) {
format(data, Action.ADD);
}
public void remove(KitBlockData data) {
format(data, Action.REMOVE);
}
public void remove(Kit kit) {
for (KitBlockData data : instance.getKitManager().getKitLocations().values()) {
if (data.getKit() != kit) continue;
remove(data);
}
}
public void update(KitBlockData data) {
format(data, Action.UPDATE);
}
public void update(Kit kit) {
for (KitBlockData data : instance.getKitManager().getKitLocations().values()) {
if (data.getKit() != kit) continue;
update(data);
}
}
private void format(KitBlockData data, Action action) {
KitType kitType = data.getType();
ArrayList<String> lines = new ArrayList<>();
List<String> order = instance.getConfig().getStringList("Main.Hologram Layout");
Kit kit = data.getKit();
for (String o : order) {
switch (o.toUpperCase()) {
case "{TITLE}":
String title = kit.getTitle();
if (title == null) {
lines.add(Methods.formatText("&5" + Methods.formatText(kit.getName(), true)));
} else {
lines.add(Methods.formatText("&5" + Methods.formatText(title)));
}
break;
case "{RIGHT-CLICK}":
if (kitType == KitType.CRATE) {
lines.add(Methods.formatText(Lang.OPEN_CRATE_HOLOGRAM.getConfigValue()));
break;
}
if (kit.getLink() != null) {
lines.add(Methods.formatText(Lang.BUY_LINK_HOLOGRAM.getConfigValue()));
break;
}
if (kit.getPrice() != 0) {
double cost = kit.getPrice();
if (cost != 0) {
lines.add(Methods.formatText(Lang.BUY_ECO_HOLOGRAM.getConfigValue(Methods.formatEconomy(cost))));
} else {
lines.add(Lang.BUY_ECO_HOLOGRAM.getConfigValue(Methods.formatText(Lang.FREE.getConfigValue())));
}
}
break;
case "{LEFT-CLICK}":
if (kitType == KitType.CLAIM) {
lines.add(Methods.formatText(Lang.DAILY_HOLOGRAM.getConfigValue(kit)));
break;
}
if (kit.getLink() == null && kit.getPrice() == 0) {
lines.add(Methods.formatText(Lang.PREVIEW_ONLY_HOLOGRAM.getConfigValue(kit)));
} else {
lines.add(Methods.formatText(Lang.PREVIEW_HOLOGRAM.getConfigValue(kit)));
}
break;
default:
lines.add(Methods.formatText(o));
break;
}
}
double multi = .25 * lines.size();
Location location = data.getLocation();
Block b = location.getBlock();
if (data.isDisplayingItems()) multi += .40;
if (b.getType() == Material.TRAPPED_CHEST
|| b.getType() == Material.CHEST
|| b.getType() == Material.SIGN
|| b.getType() == Material.ENDER_CHEST) multi -= .15;
location.add(0, multi, 0);
if (!data.showHologram()) {
remove(location);
return;
}
switch (action) {
case UPDATE:
update(location, lines);
break;
case ADD:
add(location, lines);
break;
case REMOVE:
remove(location);
break;
}
}
protected abstract void add(Location location, ArrayList<String> lines);
protected abstract void remove(Location location);
protected abstract void update(Location location, ArrayList<String> lines);
public enum Action {
UPDATE, ADD, REMOVE
}
}

View File

@ -0,0 +1,48 @@
package com.songoda.ultimatekits.hologram;
import com.songoda.arconix.api.hologram.HologramObject;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.UltimateKits;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.util.ArrayList;
import java.util.List;
public class HologramArconix extends Hologram {
private com.songoda.arconix.api.packets.Hologram hologramManager;
public HologramArconix(UltimateKits instance) {
super(instance);
this.hologramManager = Arconix.pl().getApi().packetLibrary.getHologramManager();
}
@Override
public void add(Location location, ArrayList<String> lines) {
fixLocation(location);
HologramObject hologram = new HologramObject(null, location, lines);
hologramManager.addHologram(hologram);
}
@Override
public void remove(Location location) {
fixLocation(location);
location.add(0, 0.25, 0);
hologramManager.removeHologram(location, 5);
}
@Override
public void update(Location location, ArrayList<String> lines) {
remove(location.clone());
fixLocation(location);
HologramObject hologram = new HologramObject(null, location, lines);
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(), () -> {
hologramManager.addHologram(hologram);
}, 1L);
}
private void fixLocation(Location location) {
location.add(0.5, 0.75, 0.5);
}
}

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatekits.key;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.utils.Debugger;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@ -37,16 +37,16 @@ public class Key {
String kitName;
if (kit != null)
kitName = Arconix.pl().getApi().format().formatText(kit.getShowableName(), true);
kitName = Methods.formatText(kit.getShowableName(), true);
else
kitName = "Any";
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(Arconix.pl().getApi().format().formatText(Lang.KEY_TITLE.getConfigValue(kitName)));
meta.setDisplayName(Methods.formatText(Lang.KEY_TITLE.getConfigValue(kitName)));
meta.addEnchant(Enchantment.DURABILITY, 1, true);
List<String> lore = new ArrayList<>();
lore.add(Arconix.pl().getApi().format().formatText("&e" + name + " &fKey"));
lore.add(Methods.formatText("&e" + name + " &fKey"));
String desc1 = Lang.KEY_DESC1.getConfigValue(kitName);
@ -55,13 +55,13 @@ public class Key {
else
desc1 = desc1.replace("[", "").replace("]", "");
lore.add(Arconix.pl().getApi().format().formatText(desc1));
lore.add(Methods.formatText(desc1));
if (this.amt == -1)
lore.add(Arconix.pl().getApi().format().formatText(Lang.KEY_DESC2.getConfigValue()));
lore.add(Methods.formatText(Lang.KEY_DESC2.getConfigValue()));
else
lore.add(Arconix.pl().getApi().format().formatText(Lang.KEY_DESC3.getConfigValue()));
lore.add(Methods.formatText(Lang.KEY_DESC3.getConfigValue()));
if (kitAmount > 1)
lore.add(Arconix.pl().getApi().format().formatText(Lang.KEY_DESC4.getConfigValue(this.kitAmount)));
lore.add(Methods.formatText(Lang.KEY_DESC4.getConfigValue(this.kitAmount)));
meta.setLore(lore);
is.setItemMeta(meta);

View File

@ -1,7 +1,5 @@
package com.songoda.ultimatekits.kit;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.gui.GUIConfirmBuy;
@ -48,7 +46,7 @@ public class Kit {
public Kit(String name, String title, String link, double price, Material displayItem, int delay, boolean hidden, List<KitItem> contents, KitAnimation kitAnimation) {
this.name = name;
this.showableName = Arconix.pl().getApi().format().formatText(name, true);
this.showableName = Methods.formatText(name, true);
this.price = price;
this.link = link;
this.kitAnimation = kitAnimation;
@ -78,7 +76,7 @@ public class Kit {
if (link != null) {
player.sendMessage("");
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&a" + link));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&a" + link));
player.sendMessage("");
player.closeInventory();
} else if (price != 0) {
@ -124,7 +122,7 @@ public class Kit {
public void give(Player player, boolean useKey, boolean economy, boolean console) {
try {
if (plugin.getConfig().getBoolean("Main.Prevent The Redeeming of a Kit When Inventory Is Full") && !hasRoom(player, useKey)) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.INVENTORY_FULL.getConfigValue()));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.INVENTORY_FULL.getConfigValue()));
return;
}
if (plugin.getConfig().getBoolean("Main.Sounds Enabled") && kitAnimation == KitAnimation.NONE) {
@ -138,12 +136,12 @@ public class Kit {
Key key = plugin.getKeyManager().getKey(ChatColor.stripColor(player.getItemInHand().getItemMeta().getLore().get(0)).replace(" Key", ""));
if (!player.getItemInHand().getItemMeta().getDisplayName().equals(Lang.KEY_TITLE.getConfigValue(showableName)) && !player.getItemInHand().getItemMeta().getDisplayName().equals(Lang.KEY_TITLE.getConfigValue("Any"))) {
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + Lang.WRONG_KEY.getConfigValue()));
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + Lang.WRONG_KEY.getConfigValue()));
return;
}
for (int i = 0; i < key.getKitAmount(); i++)
givePartKit(player, key);
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.KEY_SUCCESS.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.KEY_SUCCESS.getConfigValue(showableName)));
if (player.getInventory().getItemInHand().getAmount() != 1) {
ItemStack is = player.getItemInHand();
is.setAmount(is.getAmount() - 1);
@ -155,19 +153,19 @@ public class Kit {
}
if (getNextUse(player) == -1 && !economy && !console) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
} else if (getNextUse(player) <= 0 || economy || console) {
giveKit(player);
if (economy) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.PURCHASE_SUCCESS.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.PURCHASE_SUCCESS.getConfigValue(showableName)));
} else {
updateDelay(player);
if (kitAnimation == KitAnimation.NONE) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.GIVE_SUCCESS.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.GIVE_SUCCESS.getConfigValue(showableName)));
}
}
} else {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(player)))));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.DELAY.getConfigValue(Methods.makeReadable(getNextUse(player)))));
}
} catch (Exception ex) {
@ -209,7 +207,7 @@ public class Kit {
ItemMeta meta = is.getItemMeta();
List<String> newLore = new ArrayList<>();
for (String line : meta.getLore()) {
if (line.equals(TextComponent.convertToInvisibleString("----"))) break;
if (line.equals(Methods.convertToInvisibleString("----"))) break;
newLore.add(line);
}
meta.setLore(newLore);
@ -291,7 +289,7 @@ public class Kit {
if (item.getContent() instanceof KitContentEconomy) {
try {
Methods.pay(player, ((KitContentEconomy) item.getContent()).getAmount());
player.sendMessage(Lang.ECO_SENT.getConfigValue(Arconix.pl().getApi().format().formatEconomy(((KitContentEconomy) item.getContent()).getAmount())));
player.sendMessage(Lang.ECO_SENT.getConfigValue(Methods.formatEconomy(((KitContentEconomy) item.getContent()).getAmount())));
} catch (NumberFormatException ex) {
Debugger.runReport(ex);
}
@ -354,18 +352,18 @@ public class Kit {
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
if (!hasPermission(player)) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NO_PERM.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.NO_PERM.getConfigValue(showableName)));
return;
} else if (!econ.has(player, price)) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.CANNOT_AFFORD.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.CANNOT_AFFORD.getConfigValue(showableName)));
return;
}
if (this.delay > 0) {
if (getNextUse(player) == -1) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
} else if (getNextUse(player) != 0) {
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(player)))));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.DELAY.getConfigValue(Methods.makeReadable(getNextUse(player)))));
return;
}
}

View File

@ -2,6 +2,7 @@ package com.songoda.ultimatekits.kit;
import com.songoda.ultimatekits.UltimateKits;
import org.bukkit.Location;
import org.bukkit.World;
public class KitBlockData {
@ -30,7 +31,7 @@ public class KitBlockData {
setDisplayingItems(false);
setHasParticles(false);
UltimateKits.getInstance().getDisplayItemHandler().displayItem(this);
UltimateKits.getInstance().getHologramHandler().updateHolograms();
UltimateKits.getInstance().getHologram().remove(this);
}
public Kit getKit() {
@ -40,6 +41,22 @@ public class KitBlockData {
public Location getLocation() {
return location.clone();
}
public int getX() {
return location.getBlockX();
}
public int getY() {
return location.getBlockY();
}
public int getZ() {
return location.getBlockZ();
}
public World getWorld() {
return location.getWorld();
}
public boolean showHologram() {
return hologram;
@ -80,5 +97,6 @@ public class KitBlockData {
public void setType(KitType type) {
this.type = type;
}
}

View File

@ -1,12 +1,12 @@
package com.songoda.ultimatekits.kit;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.type.KitContent;
import com.songoda.ultimatekits.kit.type.KitContentCommand;
import com.songoda.ultimatekits.kit.type.KitContentEconomy;
import com.songoda.ultimatekits.kit.type.KitContentItem;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -152,7 +152,7 @@ public class KitItem {
ItemStack item = content.getItemForDisplay();
ItemMeta meta = item.getItemMeta();
if (chance != 0 || displayItem != null || displayName != null || displayLore != null) {
meta.setDisplayName(meta.hasDisplayName() ? TextComponent.convertToInvisibleString(compileOptions() + ";") + meta.getDisplayName() : TextComponent.convertToInvisibleString(compileOptions() + ";faqe") + item.getType().name().replace("_", " "));
meta.setDisplayName(meta.hasDisplayName() ? Methods.convertToInvisibleString(compileOptions() + ";") + meta.getDisplayName() : Methods.convertToInvisibleString(compileOptions() + ";faqe") + item.getType().name().replace("_", " "));
}
item.setItemMeta(meta);
return item;
@ -166,10 +166,10 @@ public class KitItem {
item.setType(displayItem);
}
if (displayName != null) {
meta.setDisplayName(TextComponent.formatText(displayName));
meta.setDisplayName(Methods.formatText(displayName));
}
if (displayLore != null) {
meta.setLore(Arrays.asList(TextComponent.formatText(displayLore)));
meta.setLore(Arrays.asList(Methods.formatText(displayLore)));
}
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Display Chance In Preview")) {
@ -181,7 +181,7 @@ public class KitItem {
}
if (lore.size() != 0) lore.addFirst("");
lore.addFirst(TextComponent.formatText("&7" + Lang.CHANCE.getConfigValue() + ": &6" + (chance == 0 ? 100 : chance) + "%"));
lore.addFirst(Methods.formatText("&7" + Lang.CHANCE.getConfigValue() + ": &6" + (chance == 0 ? 100 : chance) + "%"));
meta.setLore(new ArrayList<>(lore));
}

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatekits.kit.type;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -32,7 +32,7 @@ public class KitContentCommand implements KitContent {
ArrayList<String> lore = new ArrayList<>();
int index = 0;
while (index < command.length()) {
lore.add(TextComponent.formatText("&a" + (index == 0 ? "/" : "") + "&a" + command.substring(index, Math.min(index + 30, command.length()))));
lore.add(Methods.formatText("&a" + (index == 0 ? "/" : "") + "&a" + command.substring(index, Math.min(index + 30, command.length()))));
index += 30;
}
meta.setLore(lore);

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatekits.kit.type;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -35,7 +35,7 @@ public class KitContentEconomy implements KitContent {
int index = 0;
while (index < String.valueOf(amount).length()) {
lore.add(TextComponent.formatText("&a" + (index == 0 ? UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol") : "") + "&a" + String.valueOf(amount).substring(index, Math.min(index + 30, String.valueOf(amount).length()))));
lore.add(Methods.formatText("&a" + (index == 0 ? UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol") : "") + "&a" + String.valueOf(amount).substring(index, Math.min(index + 30, String.valueOf(amount).length()))));
index += 30;
}
meta.setLore(lore);

View File

@ -1,11 +1,10 @@
package com.songoda.ultimatekits.tasks;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.api.methods.inventory.AInventory;
import com.songoda.ultimatekits.Lang;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.kit.Kit;
import com.songoda.ultimatekits.kit.KitItem;
import com.songoda.ultimatekits.utils.Methods;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -41,7 +40,7 @@ public class CrateAnimateTask extends BukkitRunnable {
this.plugin = plugin;
this.player = player;
this.give = give;
this.inventory = Bukkit.createInventory(null, 27, TextComponent.formatText(kit.getShowableName()));
this.inventory = Bukkit.createInventory(null, 27, Methods.formatText(kit.getShowableName()));
List<KitItem> items = kit.getContents();
Collections.shuffle(items);
@ -85,7 +84,7 @@ public class CrateAnimateTask extends BukkitRunnable {
num = slow ? 1 : 0;
for (int i = 0; i < 27; i++) {
inventory.setItem(i, AInventory.toGlass(true, 0));
inventory.setItem(i, Methods.toGlass(true, 0));
}
for (int i = 9; i < 18; i++) {
@ -115,7 +114,7 @@ public class CrateAnimateTask extends BukkitRunnable {
player.getWorld().dropItemNaturally(player.getLocation(), item2);
}
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 10f, 10f);
player.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText(Lang.CRATE_WON.getConfigValue(WordUtils.capitalize(give.getType().name().toLowerCase().replace("_", " ")))));
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText(Lang.CRATE_WON.getConfigValue(WordUtils.capitalize(give.getType().name().toLowerCase().replace("_", " ")))));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, this::finish, 50);
}
done = true;

View File

@ -0,0 +1,67 @@
package com.songoda.ultimatekits.utils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
/**
* ConfigWrapper made by @clip
*/
public class ConfigWrapper {
private final JavaPlugin plugin;
private final String folderName, fileName;
private FileConfiguration config;
private File configFile;
public ConfigWrapper(final JavaPlugin instance, final String folderName, final String fileName) {
this.plugin = instance;
this.folderName = folderName;
this.fileName = fileName;
}
public void createNewFile(final String message, final String header) {
reloadConfig();
saveConfig();
loadConfig(header);
if (message != null) {
plugin.getLogger().info(message);
}
}
public FileConfiguration getConfig() {
if (config == null) {
reloadConfig();
}
return config;
}
public void loadConfig(final String header) {
config.options().header(header);
config.options().copyDefaults(true);
saveConfig();
}
public void reloadConfig() {
if (configFile == null) {
configFile = new File(plugin.getDataFolder() + folderName, fileName);
}
config = YamlConfiguration.loadConfiguration(configFile);
}
public void saveConfig() {
if (config == null || configFile == null) {
return;
}
try {
getConfig().save(configFile);
} catch (final IOException ex) {
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
}
}
}

View File

@ -19,7 +19,6 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.UltimateKits;
public class ItemSerializer {
@ -148,7 +147,7 @@ public class ItemSerializer {
item.setDurability(Short.parseShort(val[1]));
}
if (splited.length >= 2) {
if (Arconix.pl().getApi().doMath().isNumeric(splited[1])) {
if (Methods.isNumeric(splited[1])) {
item.setAmount(Integer.parseInt(splited[1]));
}
@ -184,7 +183,7 @@ public class ItemSerializer {
String[] parts = value.split("\\|");
ArrayList<String> lore = new ArrayList<>();
for (String line : parts)
lore.add(Arconix.pl().getApi().format().formatText(line));
lore.add(Methods.formatText(line));
meta.setLore(lore);
break;
case "player":

View File

@ -1,13 +1,16 @@
package com.songoda.ultimatekits.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.UUID;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.apache.commons.codec.binary.Base64;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -23,7 +26,6 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.UltimateKits;
import net.milkbowl.vault.economy.Economy;
@ -35,27 +37,43 @@ public class Methods {
public static ItemStack getGlass() {
UltimateKits plugin = UltimateKits.getInstance();
return Arconix.pl().getApi().getGUI().getGlass(plugin.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), plugin.getConfig().getInt("Interfaces.Glass Type 1"));
try {
UltimateKits instance = UltimateKits.getInstance();
return Methods.getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
} catch (Exception e) {
Debugger.runReport(e);
}
return null;
}
public static ItemStack getBackgroundGlass(boolean type) {
UltimateKits plugin = UltimateKits.getInstance();
if (type)
return Arconix.pl().getApi().getGUI().getGlass(false, plugin.getConfig().getInt("Interfaces.Glass Type 2"));
else
return Arconix.pl().getApi().getGUI().getGlass(false, plugin.getConfig().getInt("Interfaces.Glass Type 3"));
try {
UltimateKits instance = UltimateKits.getInstance();
if (type)
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
else
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
} catch (Exception e) {
Debugger.runReport(e);
}
return null;
}
public static void fillGlass(Inventory i) {
int nu = 0;
while (nu != 27) {
ItemStack glass = getGlass();
i.setItem(nu, glass);
nu++;
private static ItemStack getGlass(Boolean rainbow, int type) {
int randomNum = 1 + (int) (Math.random() * 6);
ItemStack glass;
if (rainbow) {
glass = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE, 1, (short) randomNum);
} else {
glass = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE, 1, (short) type);
}
ItemMeta glassmeta = glass.getItemMeta();
glassmeta.setDisplayName("§l");
glass.setItemMeta(glassmeta);
return glass;
}
public static boolean canGiveKit(Player player) {
try {
if (player.hasPermission("ultimatekits.cangive")) return true;
@ -76,9 +94,213 @@ public class Methods {
econ.depositPlayer(p, amount);
return true;
}
public static String getKitFromLocation(Location location) {
return UltimateKits.getInstance().getConfig().getString("data.block." + Arconix.pl().getApi().serialize().serializeLocation(location));
return UltimateKits.getInstance().getConfig().getString("data.block." + serializeLocation(location));
}
/**
* Serializes the location of the block specified.
*
* @param b The block whose location is to be saved.
* @return The serialized data.
*/
public static String serializeLocation(Block b) {
if (b == null)
return "";
return serializeLocation(b.getLocation());
}
/**
* Serializes the location specified.
*
* @param location The location that is to be saved.
* @return The serialized data.
*/
public static String serializeLocation(Location location) {
if (location == null)
return "";
String w = location.getWorld().getName();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
String str = w + ":" + x + ":" + y + ":" + z;
str = str.replace(".0", "").replace("/", "");
return str;
}
private static Map<String, Location> serializeCache = new HashMap<>();
/**
* Deserializes a location from the string.
*
* @param str The string to parse.
* @return The location that was serialized in the string.
*/
public static Location unserializeLocation(String str) {
if (str == null || str.equals(""))
return null;
if (serializeCache.containsKey(str)) {
return serializeCache.get(str).clone();
}
String cacheKey = str;
str = str.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
List<String> args = Arrays.asList(str.split("\\s*:\\s*"));
World world = Bukkit.getWorld(args.get(0));
double x = Double.parseDouble(args.get(1)), y = Double.parseDouble(args.get(2)), z = Double.parseDouble(args.get(3));
Location location = new Location(world, x, y, z, 0, 0);
serializeCache.put(cacheKey, location.clone());
return location;
}
public static String convertToInvisibleString(String s) {
if (s == null || s.equals(""))
return "";
StringBuilder hidden = new StringBuilder();
for (char c : s.toCharArray()) hidden.append(ChatColor.COLOR_CHAR + "").append(c);
return hidden.toString();
}
public static String formatTitle(String text) {
if (text == null || text.equals(""))
return "";
/* if (UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_9)) {
if (text.length() > 31)
text = text.substring(0, 29) + "...";
} */
text = formatText(text);
return text;
}
public static String formatText(String text) {
if (text == null || text.equals(""))
return "";
return formatText(text, false);
}
public static String formatText(String text, boolean cap) {
if (text == null || text.equals(""))
return "";
if (cap)
text = text.substring(0, 1).toUpperCase() + text.substring(1);
return ChatColor.translateAlternateColorCodes('&', text);
}
/**
* Makes the specified Unix Epoch time human readable as per the format settings in the Arconix config.
*
* @param time The time to convert.
* @return A human readable string representing to specified time.
*/
public static String makeReadable(Long time) {
if (time == null)
return "";
return String.format("%d hour(s), %d min(s), %d sec(s)", TimeUnit.MILLISECONDS.toHours(time), TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)), TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time)));
}
/**
* Formats the specified double into the Economy format specified in the Arconix config.
*
* @param amt The double to format.
* @return The economy formatted double.
*/
public static String formatEconomy(double amt) {
DecimalFormat formatter = new DecimalFormat("#,###.00");
return formatter.format(amt);
}
public static boolean isInt(String number) {
if (number == null || number.equals(""))
return false;
try {
Integer.parseInt(number);
} catch (NumberFormatException e) {
return false;
}
return true;
}
/**
* Determines if the provided string is a valid number (int, double, float, or otherwise).
*
* @param s The string to check.
* @return <code>true</code> if the string is numeric, otherwise <code>false</code>
*/
public static boolean isNumeric(String s) {
if (s == null || s.equals(""))
return false;
return s.matches("[-+]?\\d*\\.?\\d+");
}
/**
* Fills the provided inventory with glass panes of the specified color type.
*
* @param i The inventory to fill.
*/
public static void fillGlass(Inventory i) {
ItemStack glass = getGlass();
ItemMeta glassMeta = glass.getItemMeta();
glassMeta.setDisplayName("§5");
glass.setItemMeta(glassMeta);
int nu = 0;
while (nu != 27) {
i.setItem(nu, glass);
nu++;
}
}
/**
* Adds the specified texture to the supplied head itemstack.
*
* @param item A head to apply the texture to.
* @param headURL The URL of the texture to apply.
* @return The head with the textrue.
*/
public static ItemStack addTexture(ItemStack item, String headURL) {
SkullMeta meta = (SkullMeta) item.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[]{headURL}).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField;
try {
profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (Exception e) {
e.printStackTrace();
}
item.setItemMeta(meta);
return item;
}
/**
* Creates a glass itemstack
*
* @param rainbow Whether or not to assign a random color to the glass.
* @param type If rainbow is false, the glass color.
* @return A glass itemstack conforming to the params.
*/
public static ItemStack toGlass(Boolean rainbow, int type) {
int randomNum = 1 + (int) (Math.random() * 6);
ItemStack glass;
if (rainbow) {
glass = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE, 1, (short) randomNum);
} else {
glass = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE, 1, (short) type);
}
ItemMeta glassMeta = glass.getItemMeta();
glassMeta.setDisplayName("§l");
glass.setItemMeta(glassMeta);
return glass;
}
}

View File

@ -1,7 +1,5 @@
package com.songoda.ultimatekits.utils;
import com.songoda.arconix.api.utils.ConfigWrapper;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.ultimatekits.UltimateKits;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -117,9 +115,9 @@ public class SettingsManager implements Listener {
this.current.put(p, ChatColor.stripColor(current));
p.closeInventory();
p.sendMessage("");
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Please enter a value for &6" + current + "&7."));
p.sendMessage(Methods.formatText("&7Please enter a value for &6" + current + "&7."));
if (instance.getConfig().get(current).getClass().getName().equals("java.lang.Integer")) {
p.sendMessage(Arconix.pl().getApi().format().formatText("&cUse only numbers."));
p.sendMessage(Methods.formatText("&cUse only numbers."));
}
p.sendMessage("");
}
@ -136,8 +134,8 @@ public class SettingsManager implements Listener {
for (String key : instance.getConfig().getConfigurationSection("").getKeys(false)) {
ItemStack item = new ItemStack(Material.WHITE_WOOL, 1, (byte) (spot - 9)); //ToDo: Make this function as it was meant to.
ItemMeta meta = item.getItemMeta();
meta.setLore(Collections.singletonList(Arconix.pl().getApi().format().formatText("&6Click To Edit This Category.")));
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&f&l" + key));
meta.setLore(Collections.singletonList(Methods.formatText("&6Click To Edit This Category.")));
meta.setDisplayName(Methods.formatText("&f&l" + key));
item.setItemMeta(meta);
i.setItem(spot, item);
spot++;
@ -153,7 +151,7 @@ public class SettingsManager implements Listener {
String fKey = cat.get(p) + "." + key;
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&6" + key));
meta.setDisplayName(Methods.formatText("&6" + key));
ArrayList<String> lore = new ArrayList<>();
switch (instance.getConfig().get(fKey).getClass().getName()) {
case "java.lang.Boolean":
@ -162,21 +160,21 @@ public class SettingsManager implements Listener {
boolean bool = (Boolean) instance.getConfig().get(fKey);
if (!bool)
lore.add(Arconix.pl().getApi().format().formatText("&c" + false));
lore.add(Methods.formatText("&c" + false));
else
lore.add(Arconix.pl().getApi().format().formatText("&a" + true));
lore.add(Methods.formatText("&a" + true));
break;
case "java.lang.String":
item.setType(Material.PAPER);
String str = (String) instance.getConfig().get(fKey);
lore.add(Arconix.pl().getApi().format().formatText("&9" + str));
lore.add(Methods.formatText("&9" + str));
break;
case "java.lang.Integer":
item.setType(Material.CLOCK);
int in = (Integer) instance.getConfig().get(fKey);
lore.add(Arconix.pl().getApi().format().formatText("&5" + in));
lore.add(Methods.formatText("&5" + in));
break;
default:
continue;
@ -188,7 +186,7 @@ public class SettingsManager implements Listener {
Matcher m = regex.matcher(text);
while (m.find()) {
if (m.end() != text.length() || m.group().length() != 0)
lore.add(Arconix.pl().getApi().format().formatText("&7" + m.group()));
lore.add(Methods.formatText("&7" + m.group()));
}
}
meta.setLore(lore);

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatekits.utils.gui;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.ultimatekits.UltimateKits;
import com.songoda.ultimatekits.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -116,7 +116,7 @@ public abstract class AbstractGUI implements Listener {
if (inventory == null
|| inventory.getSize() != slots
|| ChatColor.translateAlternateColorCodes('&', title) != inventory.getTitle()) {
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, TextComponent.formatTitle(title));
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatTitle(title));
if (this.clickables.size() == 0)
registerClickables();
if (this.onCloses.size() == 0)