mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-09-06 03:08:02 +02:00
General cleanup and polish
This commit is contained in:
parent
49d2c70ece
commit
bdb3703481
@ -27,10 +27,11 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.*;
|
||||
|
||||
public class UltimateKits extends JavaPlugin {
|
||||
private static CommandSender console = Bukkit.getConsoleSender();
|
||||
private static UltimateKits INSTANCE;
|
||||
public References references;
|
||||
public DisplayItemHandler displayitem;
|
||||
|
||||
private static CommandSender console = Bukkit.getConsoleSender();
|
||||
private References references;
|
||||
private DisplayItemHandler displayItemHandler;
|
||||
|
||||
private ConfigWrapper langFile = new ConfigWrapper(this, "", "lang.yml");
|
||||
private ConfigWrapper kitFile = new ConfigWrapper(this, "", "kit.yml");
|
||||
@ -91,11 +92,10 @@ public class UltimateKits extends JavaPlugin {
|
||||
|
||||
new Convert(this);
|
||||
|
||||
references = new References();
|
||||
this.references = new References();
|
||||
|
||||
hologramHandler = new HologramHandler(this);
|
||||
new ParticleHandler(this);
|
||||
displayitem = new DisplayItemHandler(this);
|
||||
this.displayItemHandler = new DisplayItemHandler(this);
|
||||
|
||||
settingsManager = new SettingsManager(this);
|
||||
settingsManager.updateSettings();
|
||||
@ -107,6 +107,7 @@ public class UltimateKits extends JavaPlugin {
|
||||
this.blockEditor = new BlockEditor(this);
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.playerDataManager = new PlayerDataManager();
|
||||
this.hologramHandler = new HologramHandler(this);
|
||||
|
||||
loadFromFile();
|
||||
|
||||
@ -303,7 +304,7 @@ public class UltimateKits extends JavaPlugin {
|
||||
kitFile.reloadConfig();
|
||||
langFile.reloadConfig();
|
||||
loadLanguageFile();
|
||||
references = new References();
|
||||
this.references = new References();
|
||||
reloadConfig();
|
||||
loadFromFile();
|
||||
hologramHandler.updateHolograms();
|
||||
@ -382,4 +383,12 @@ public class UltimateKits extends JavaPlugin {
|
||||
public PlayerDataManager getPlayerDataManager() {
|
||||
return playerDataManager;
|
||||
}
|
||||
|
||||
public References getReferences() {
|
||||
return references;
|
||||
}
|
||||
|
||||
public DisplayItemHandler getDisplayItemHandler() {
|
||||
return displayItemHandler;
|
||||
}
|
||||
}
|
||||
|
@ -15,16 +15,16 @@ import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
|
||||
private UltimateKits instance;
|
||||
private UltimateKits plugin;
|
||||
|
||||
private List<AbstractCommand> commands = new ArrayList<>();
|
||||
|
||||
public CommandManager(UltimateKits instance) {
|
||||
this.instance = instance;
|
||||
public CommandManager(UltimateKits plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
instance.getCommand("UltimateKits").setExecutor(this);
|
||||
instance.getCommand("PreviewKit").setExecutor(this);
|
||||
instance.getCommand("Kits").setExecutor(this);
|
||||
plugin.getCommand("UltimateKits").setExecutor(this);
|
||||
plugin.getCommand("PreviewKit").setExecutor(this);
|
||||
plugin.getCommand("Kits").setExecutor(this);
|
||||
|
||||
AbstractCommand commandUltimateKits = addCommand(new CommandUltimateKits());
|
||||
|
||||
@ -61,7 +61,7 @@ public class CommandManager implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
commandSender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
commandSender.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,14 +71,14 @@ public class CommandManager implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings);
|
||||
AbstractCommand.ReturnType returnType = command.runCommand(plugin, sender, strings);
|
||||
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
|
||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cInvalid Syntax!"));
|
||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||
sender.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText("&cInvalid Syntax!"));
|
||||
sender.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(instance.references.getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
sender.sendMessage(plugin.getReferences().getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
}
|
||||
|
||||
public List<AbstractCommand> getCommands() {
|
||||
|
@ -20,11 +20,11 @@ public class CommandCreatekit extends AbstractCommand {
|
||||
if (args.length != 2) return ReturnType.SYNTAX_ERROR;
|
||||
String kitStr = args[1].toLowerCase();
|
||||
if (instance.getKitManager().getKit(kitStr) != null) {
|
||||
p.sendMessage(instance.references.getPrefix() + Lang.KIT_ALREADY_EXISTS.getConfigValue(kitStr));
|
||||
p.sendMessage(instance.getReferences().getPrefix() + Lang.KIT_ALREADY_EXISTS.getConfigValue(kitStr));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText("&aThat kit doesn't exist. Creating it now."));
|
||||
p.sendMessage(UltimateKits.getInstance().getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&aThat kit doesn't exist. Creating it now."));
|
||||
Kit kit = new Kit(kitStr.trim());
|
||||
UltimateKits.getInstance().getKitManager().addKit(kit);
|
||||
instance.getKitEditor().openOverview(kit, p, false, null, 0);
|
||||
|
@ -25,14 +25,14 @@ public class CommandEdit extends AbstractCommand {
|
||||
|
||||
if (args.length == 1) {
|
||||
if (instance.getConfig().getString("data.block." + loc) == null) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8This block does not contain a kit."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8This block does not contain a kit."));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
instance.getBlockEditor().openOverview(player, block.getLocation());
|
||||
} else {
|
||||
String kitStr = args[1].toLowerCase().trim();
|
||||
if (instance.getKitManager().getKit(kitStr) == null) {
|
||||
player.sendMessage(instance.references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kitStr));
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kitStr));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ public class CommandKey extends AbstractCommand {
|
||||
}
|
||||
Kit kit = instance.getKitManager().getKit(args[1]);
|
||||
if (kit == null && !args[1].toLowerCase().equals("all")) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kit));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kit));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
if (Bukkit.getPlayer(args[3]) == null && !args[3].trim().equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is offline!"));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is offline!"));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
int amt = 1;
|
||||
@ -39,13 +39,13 @@ public class CommandKey extends AbstractCommand {
|
||||
}
|
||||
}
|
||||
if (amt == 0) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText("&a" + args[3] + " &cis not a number."));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&a" + args[3] + " &cis not a number."));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Key key = instance.getKeyManager().getKey(args[2]);
|
||||
if (key == null) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText("&a" + args[3] + " &cis not a key."));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&a" + args[3] + " &cis not a key."));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
@ -53,12 +53,12 @@ public class CommandKey extends AbstractCommand {
|
||||
if (!args[3].trim().equals("all")) {
|
||||
Player p = Bukkit.getPlayer(args[3]);
|
||||
p.getInventory().addItem(key.getKeyItem(kit, amt));
|
||||
p.sendMessage(instance.references.getPrefix() + Lang.KEY_GIVEN.getConfigValue((kit == null ? "Any" : kit.getShowableName())));
|
||||
p.sendMessage(instance.getReferences().getPrefix() + Lang.KEY_GIVEN.getConfigValue((kit == null ? "Any" : kit.getShowableName())));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
for (Player pl : instance.getServer().getOnlinePlayers()) {
|
||||
pl.getInventory().addItem(key.getKeyItem(kit, amt));
|
||||
pl.sendMessage(instance.references.getPrefix() + Lang.KEY_GIVEN.getConfigValue((kit == null ? "Any" : kit.getShowableName())));
|
||||
pl.sendMessage(instance.getReferences().getPrefix() + Lang.KEY_GIVEN.getConfigValue((kit == null ? "Any" : kit.getShowableName())));
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class CommandKits extends AbstractCommand {
|
||||
Player p = (Player) sender;
|
||||
String kitName = args[0].toLowerCase();
|
||||
if (instance.getKitManager().getKit(kitName) == null) {
|
||||
p.sendMessage(instance.references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kitName));
|
||||
p.sendMessage(instance.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kitName));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
Kit kit = instance.getKitManager().getKit(kitName);
|
||||
@ -41,28 +41,28 @@ public class CommandKits extends AbstractCommand {
|
||||
if (args.length == 2) {
|
||||
String kitName = args[0].toLowerCase();
|
||||
if (instance.getKitManager().getKit(kitName) == null) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kitName));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kitName));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Lang.PLAYER_NOT_FOUND.getConfigValue(kitName));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Lang.PLAYER_NOT_FOUND.getConfigValue(kitName));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
Player p2 = Bukkit.getPlayer(args[1]);
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (!Methods.canGiveKit(p)) {
|
||||
p.sendMessage(instance.references.getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
p.sendMessage(instance.getReferences().getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
}
|
||||
Kit kit = instance.getKitManager().getKit(kitName);
|
||||
kit.give(p2, false, false, true);
|
||||
sender.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText("&7You gave &9" + p2.getDisplayName() + "&7 kit &9" + kit.getShowableName() + "&7."));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&7You gave &9" + p2.getDisplayName() + "&7 kit &9" + kit.getShowableName() + "&7."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
sender.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.SYNTAX.getConfigValue()));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.SYNTAX.getConfigValue()));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -14,15 +14,15 @@ public class CommandPreviewKit extends AbstractCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(UltimateKits plugin, CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
if (args.length != 1) {
|
||||
player.sendMessage(instance.references.getPrefix() + Lang.PREVIEW_NO_KIT_SUPPLIED.getConfigValue());
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Lang.PREVIEW_NO_KIT_SUPPLIED.getConfigValue());
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
Kit kit = instance.getKitManager().getKit(args[0].toLowerCase().trim());
|
||||
Kit kit = plugin.getKitManager().getKit(args[0].toLowerCase().trim());
|
||||
if (kit == null) {
|
||||
player.sendMessage(instance.references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue());
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue());
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
kit.display(player, false);
|
||||
|
@ -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.references.getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,14 @@ public class CommandRemove extends AbstractCommand {
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
|
||||
if (args.length != 1) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Lang.PREVIEW_NO_KIT_SUPPLIED.getConfigValue());
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Lang.PREVIEW_NO_KIT_SUPPLIED.getConfigValue());
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Block b = player.getTargetBlock(null, 200);
|
||||
Kit kit = instance.getKitManager().removeKitFromLocation(b.getLocation());
|
||||
Block block = player.getTargetBlock(null, 200);
|
||||
Kit kit = instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
UltimateKits.getInstance().getHologramHandler().updateHolograms();
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(UltimateKits.getInstance().references.getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + b.getType().toString() + "&8."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(UltimateKits.getInstance().getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType().toString() + "&8."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,18 @@ public class CommandSet extends AbstractCommand {
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage(instance.references.getPrefix() + Lang.PREVIEW_NO_KIT_SUPPLIED.getConfigValue());
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Lang.PREVIEW_NO_KIT_SUPPLIED.getConfigValue());
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
String kit = args[1].toLowerCase();
|
||||
if (instance.getKitManager().getKit(kit) == null) {
|
||||
player.sendMessage(instance.references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kit));
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(kit));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
Block b = player.getTargetBlock(null, 200);
|
||||
instance.getKitManager().addKitToLocation(instance.getKitManager().getKit(kit), b.getLocation());
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Kit &a" + kit + " &8set to: &a" + b.getType().toString() + "&8."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Kit &a" + kit + " &8set to: &a" + b.getType().toString() + "&8."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class CommandUltimateKits extends AbstractCommand {
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(UltimateKits instance, CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna"));
|
||||
sender.sendMessage(TextComponent.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())) {
|
||||
|
@ -621,14 +621,14 @@ public class KitEditor {
|
||||
if (type) {
|
||||
ItemStack is = player.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8You must be holding an item to use this function."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8You must be holding an item to use this function."));
|
||||
return;
|
||||
}
|
||||
kit.setDisplayItem(is.getType());
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Custom Item Display set for kit &a" + kit.getShowableName() + "&8."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Custom Item Display set for kit &a" + kit.getShowableName() + "&8."));
|
||||
} else {
|
||||
kit.setDisplayItem(null);
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Custom Item Display removed from kit &a" + kit.getShowableName() + "&8."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Custom Item Display removed from kit &a" + kit.getShowableName() + "&8."));
|
||||
}
|
||||
gui(player);
|
||||
} catch (Exception ex) {
|
||||
@ -642,7 +642,7 @@ public class KitEditor {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.COMMAND) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "Editing Timed out."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "Editing Timed out."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
}
|
||||
}, 500L);
|
||||
@ -680,7 +680,7 @@ public class KitEditor {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.MONEY) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "Editing Timed out."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "Editing Timed out."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
}
|
||||
}, 500L);
|
||||
@ -715,7 +715,7 @@ public class KitEditor {
|
||||
|
||||
kit.saveKit(Arrays.asList(items));
|
||||
if (!playerData.isMuteSave())
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Changes to &a" + kit.getShowableName() + " &8saved successfully."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Changes to &a" + kit.getShowableName() + " &8saved successfully."));
|
||||
|
||||
playerData.setMuteSave(false);
|
||||
} catch (Exception ex) {
|
||||
@ -756,7 +756,7 @@ public class KitEditor {
|
||||
player.closeInventory();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.DELAY) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "Editing Timed out."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "Editing Timed out."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
}
|
||||
}, 200L);
|
||||
@ -780,7 +780,7 @@ public class KitEditor {
|
||||
player.closeInventory();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.TITLE) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "Editing Timed out."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "Editing Timed out."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
}
|
||||
}, 200L);
|
||||
@ -807,7 +807,7 @@ public class KitEditor {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.PRICE) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "Editing Timed out."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "Editing Timed out."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
}
|
||||
}, 200L);
|
||||
@ -830,7 +830,7 @@ public class KitEditor {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.LINK) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "Editing Timed out."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "Editing Timed out."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
}
|
||||
}, 200L);
|
||||
|
@ -32,7 +32,7 @@ public class BlockListeners implements Listener {
|
||||
Kit kit = kitBlockData.getKit();
|
||||
instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
instance.getHologramHandler().updateHolograms();
|
||||
event.getPlayer().sendMessage(Arconix.pl().getApi().format().formatText(UltimateKits.getInstance().references.getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8."));
|
||||
event.getPlayer().sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8."));
|
||||
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
|
@ -23,41 +23,41 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class ChatListeners implements Listener {
|
||||
|
||||
private final UltimateKits instance;
|
||||
private final UltimateKits plugin;
|
||||
|
||||
public ChatListeners(UltimateKits instance) {
|
||||
this.instance = instance;
|
||||
public ChatListeners(UltimateKits plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(AsyncPlayerChatEvent e) {
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
try {
|
||||
final Player player = e.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
KitEditorPlayerData playerData = instance.getKitEditor().getDataFor(player);
|
||||
KitEditorPlayerData playerData = plugin.getKitEditor().getDataFor(player);
|
||||
|
||||
if (playerData.getEditorType() == KitEditorPlayerData.EditorType.NOTIN) return;
|
||||
|
||||
KitEditor edit = instance.getKitEditor();
|
||||
String msg = e.getMessage().trim();
|
||||
KitEditor edit = plugin.getKitEditor();
|
||||
String msg = event.getMessage().trim();
|
||||
Kit kit = playerData.getKit();
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
|
||||
switch (playerData.getEditorType()) {
|
||||
case PRICE:
|
||||
if (instance.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
player.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText("&8You must have &aVault &8installed to utilize economy.."));
|
||||
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."));
|
||||
} else {
|
||||
|
||||
if (kit.getLink() != null) {
|
||||
kit.setLink(null);
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8LINK has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
|
||||
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.."));
|
||||
}
|
||||
Double eco = Double.parseDouble(msg);
|
||||
kit.setPrice(eco);
|
||||
instance.getHologramHandler().updateHolograms();
|
||||
plugin.getHologramHandler().updateHolograms();
|
||||
}
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
edit.selling(player);
|
||||
@ -74,18 +74,18 @@ public class ChatListeners implements Listener {
|
||||
case LINK:
|
||||
if (kit.getPrice() != 0) {
|
||||
kit.setPrice(0);
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8ECO has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
|
||||
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.."));
|
||||
}
|
||||
kit.setLink(msg);
|
||||
instance.getHologramHandler().updateHolograms();
|
||||
plugin.getHologramHandler().updateHolograms();
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
edit.selling(player);
|
||||
break;
|
||||
case TITLE:
|
||||
kit.setTitle(msg);
|
||||
instance.saveConfig();
|
||||
instance.getHologramHandler().updateHolograms();
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Title &5" + msg + "&8 added to Kit &a" + kit.getShowableName() + "&8."));
|
||||
plugin.saveConfig();
|
||||
plugin.getHologramHandler().updateHolograms();
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8Title &5" + msg + "&8 added to Kit &a" + kit.getShowableName() + "&8."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
edit.gui(player);
|
||||
break;
|
||||
@ -104,7 +104,7 @@ public class ChatListeners implements Listener {
|
||||
meta.setDisplayName(Lang.COMMAND.getConfigValue());
|
||||
parseStack.setItemMeta(meta);
|
||||
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Command &5" + msg + "&8 has been added to your kit."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8Command &5" + msg + "&8 has been added to your kit."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
edit.openOverview(kit, player, false, parseStack, 0);
|
||||
break;
|
||||
@ -123,12 +123,12 @@ public class ChatListeners implements Listener {
|
||||
meta2.setDisplayName(Lang.MONEY.getConfigValue());
|
||||
parseStack2.setItemMeta(meta2);
|
||||
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&8Money &5$" + msg + "&8 has been added to your kit."));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + "&8Money &5$" + msg + "&8 has been added to your kit."));
|
||||
playerData.setEditorType(KitEditorPlayerData.EditorType.NOTIN);
|
||||
edit.openOverview(kit, player, false, parseStack2, 0);
|
||||
break;
|
||||
default:
|
||||
e.setCancelled(false);
|
||||
event.setCancelled(false);
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -57,10 +57,10 @@ public class InteractListeners implements Listener {
|
||||
|
||||
if (kitBlockData.getType() != KitType.PREVIEW) {
|
||||
if (kitBlockData.getType() == KitType.CRATE) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + Lang.NOT_KEY.getConfigValue()));
|
||||
player.sendMessage(Arconix.pl().getApi().format().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.references.getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
return;
|
||||
}
|
||||
if (kit.getNextUse(player) <= 0) {
|
||||
@ -68,7 +68,7 @@ public class InteractListeners implements Listener {
|
||||
kit.updateDelay(player);
|
||||
} else {
|
||||
long time = kit.getNextUse(player);
|
||||
player.sendMessage(instance.references.getPrefix() + Lang.NOT_YET.getConfigValue(Arconix.pl().getApi().format().readableTime(time)));
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Lang.NOT_YET.getConfigValue(Arconix.pl().getApi().format().readableTime(time)));
|
||||
}
|
||||
}
|
||||
} else if (kit.getLink() != null || kit.getPrice() != 0) {
|
||||
|
@ -23,8 +23,8 @@ public class InventoryListeners implements Listener {
|
||||
|
||||
private final UltimateKits instance;
|
||||
|
||||
public InventoryListeners(UltimateKits instance) {
|
||||
this.instance = instance;
|
||||
public InventoryListeners(UltimateKits plugin) {
|
||||
this.instance = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -41,14 +41,14 @@ public class InventoryListeners implements Listener {
|
||||
kit.buyWithEconomy(player);
|
||||
player.closeInventory();
|
||||
} else if (event.getSlot() == 15) {
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + Lang.BUYCANCELLED.getConfigValue()));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.getReferences().getPrefix() + Lang.BUYCANCELLED.getConfigValue()));
|
||||
player.closeInventory();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
} else if (playerData.getGuiLocation() == PlayerData.GUILocation.KITS) {
|
||||
event.setCancelled(true);
|
||||
if (instance.references.isPlaySound())
|
||||
player.playSound(event.getWhoClicked().getLocation(), instance.references.getSound(), 10.0F, 1.0F);
|
||||
if (instance.getReferences().isPlaySound())
|
||||
player.playSound(event.getWhoClicked().getLocation(), instance.getReferences().getSound(), 10.0F, 1.0F);
|
||||
if (event.getAction() == InventoryAction.NOTHING
|
||||
|| event.getCurrentItem().getType() == Material.AIR
|
||||
|| event.getCurrentItem().getItemMeta().getDisplayName() == null) {
|
||||
@ -104,8 +104,8 @@ public class InventoryListeners implements Listener {
|
||||
}
|
||||
} else if (playerData.getGuiLocation() == PlayerData.GUILocation.DISPLAY) {
|
||||
event.setCancelled(true);
|
||||
if (instance.references.isPlaySound()) {
|
||||
((Player) event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), instance.references.getSound(), 10.0F, 1.0F);
|
||||
if (instance.getReferences().isPlaySound()) {
|
||||
((Player) event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), instance.getReferences().getSound(), 10.0F, 1.0F);
|
||||
}
|
||||
if (event.getAction() == InventoryAction.NOTHING
|
||||
|| event.getCurrentItem().getType() == Material.AIR
|
||||
@ -277,7 +277,7 @@ public class InventoryListeners implements Listener {
|
||||
break;
|
||||
case 15:
|
||||
instance.getKitManager().removeKit(edit.getDataFor(player).getKit());
|
||||
player.sendMessage(instance.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cKit destroyed successfully."));
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&cKit destroyed successfully."));
|
||||
player.closeInventory();
|
||||
break;
|
||||
}
|
||||
@ -309,8 +309,8 @@ public class InventoryListeners implements Listener {
|
||||
if (instance.getPlayerDataManager().getPlayerAction((Player)event.getWhoClicked()).getGuiLocation() != PlayerData.GUILocation.DISPLAY)
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
if (instance.references.isPlaySound())
|
||||
((Player) event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), instance.references.getSound(), 10.0F, 1.0F);
|
||||
if (instance.getReferences().isPlaySound())
|
||||
((Player) event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), instance.getReferences().getSound(), 10.0F, 1.0F);
|
||||
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
@ -323,8 +323,8 @@ public class InventoryListeners implements Listener {
|
||||
if (instance.getPlayerDataManager().getPlayerAction((Player)event.getWhoClicked()).getGuiLocation() != PlayerData.GUILocation.DISPLAY)
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
if (instance.references.isPlaySound())
|
||||
((Player) event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), instance.references.getSound(), 10.0F, 1.0F);
|
||||
if (instance.getReferences().isPlaySound())
|
||||
((Player) event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), instance.getReferences().getSound(), 10.0F, 1.0F);
|
||||
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
|
@ -49,6 +49,8 @@ public class Kit {
|
||||
|
||||
private KitAnimation kitAnimation;
|
||||
|
||||
private final UltimateKits plugin;
|
||||
|
||||
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);
|
||||
@ -60,33 +62,34 @@ public class Kit {
|
||||
this.hidden = hidden;
|
||||
this.displayItem = displayItem;
|
||||
this.contents = contents;
|
||||
this.plugin = UltimateKits.getInstance();
|
||||
}
|
||||
|
||||
public Kit(String name) {
|
||||
this(name, null, null, 0, null, 0, false, new ArrayList<>(), KitAnimation.NONE);
|
||||
}
|
||||
|
||||
public void buy(Player p) {
|
||||
public void buy(Player player) {
|
||||
try {
|
||||
if (hasPermission(p) && UltimateKits.getInstance().getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
|
||||
give(p, false, false, false);
|
||||
if (hasPermission(player) && plugin.getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
|
||||
give(player, false, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!p.hasPermission("ultimatekits.buy." + name)) {
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
if (!player.hasPermission("ultimatekits.buy." + name)) {
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
return;
|
||||
}
|
||||
|
||||
if (link != null) {
|
||||
p.sendMessage("");
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText("&a" + link));
|
||||
p.sendMessage("");
|
||||
p.closeInventory();
|
||||
player.sendMessage("");
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText("&a" + link));
|
||||
player.sendMessage("");
|
||||
player.closeInventory();
|
||||
} else if (price != 0) {
|
||||
confirmBuy(name, p);
|
||||
confirmBuy(name, player);
|
||||
} else {
|
||||
p.sendMessage(Lang.NO_PERM.getConfigValue());
|
||||
player.sendMessage(Lang.NO_PERM.getConfigValue());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
@ -115,7 +118,7 @@ public class Kit {
|
||||
|
||||
|
||||
if (useKey) {
|
||||
Key key = UltimateKits.getInstance().getKeyManager().getKey(ChatColor.stripColor(p.getItemInHand().getItemMeta().getLore().get(0)).replace(" Key", ""));
|
||||
Key key = plugin.getKeyManager().getKey(ChatColor.stripColor(p.getItemInHand().getItemMeta().getLore().get(0)).replace(" Key", ""));
|
||||
if (key.getAmt() != -1)
|
||||
spaceNeeded = key.getAmt();
|
||||
}
|
||||
@ -125,11 +128,11 @@ public class Kit {
|
||||
|
||||
public void give(Player player, boolean useKey, boolean economy, boolean console) {
|
||||
try {
|
||||
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Prevent The Redeeming of a Kit When Inventory Is Full") && !hasRoom(player, useKey)) {
|
||||
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.INVENTORY_FULL.getConfigValue()));
|
||||
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()));
|
||||
return;
|
||||
}
|
||||
if (UltimateKits.getInstance().getConfig().getBoolean("Main.Sounds Enabled") && kitAnimation == KitAnimation.NONE) {
|
||||
if (plugin.getConfig().getBoolean("Main.Sounds Enabled") && kitAnimation == KitAnimation.NONE) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
||||
}
|
||||
if (useKey) {
|
||||
@ -137,15 +140,15 @@ public class Kit {
|
||||
return;
|
||||
}
|
||||
|
||||
Key key = UltimateKits.getInstance().getKeyManager().getKey(ChatColor.stripColor(player.getItemInHand().getItemMeta().getLore().get(0)).replace(" Key", ""));
|
||||
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(UltimateKits.getInstance().references.getPrefix() + Lang.WRONG_KEY.getConfigValue()));
|
||||
player.sendMessage(Arconix.pl().getApi().format().formatText(plugin.getReferences().getPrefix() + Lang.WRONG_KEY.getConfigValue()));
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < key.getKitAmount(); i++)
|
||||
givePartKit(player, key);
|
||||
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.KEY_SUCCESS.getConfigValue(showableName)));
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.KEY_SUCCESS.getConfigValue(showableName)));
|
||||
if (player.getInventory().getItemInHand().getAmount() != 1) {
|
||||
ItemStack is = player.getItemInHand();
|
||||
is.setAmount(is.getAmount() - 1);
|
||||
@ -157,19 +160,19 @@ public class Kit {
|
||||
}
|
||||
|
||||
if (getNextUse(player) == -1 && !economy && !console) {
|
||||
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
|
||||
} else if (getNextUse(player) <= 0 || economy || console) {
|
||||
giveKit(player);
|
||||
if (economy) {
|
||||
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.PURCHASE_SUCCESS.getConfigValue(showableName)));
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.PURCHASE_SUCCESS.getConfigValue(showableName)));
|
||||
} else {
|
||||
updateDelay(player);
|
||||
if (kitAnimation == KitAnimation.NONE) {
|
||||
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.GIVE_SUCCESS.getConfigValue(showableName)));
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.GIVE_SUCCESS.getConfigValue(showableName)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(player)))));
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(player)))));
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
@ -185,16 +188,16 @@ public class Kit {
|
||||
&& !p.hasPermission("previewkit." + name)
|
||||
&& !p.hasPermission("ultimatekits.use")
|
||||
&& !p.hasPermission("ultimatekits." + name)) {
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Lang.NO_PERM.getConfigValue());
|
||||
return;
|
||||
}
|
||||
if (name == null) {
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(showableName));
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Lang.KIT_DOESNT_EXIST.getConfigValue(showableName));
|
||||
return;
|
||||
}
|
||||
PlayerData playerData = UltimateKits.getInstance().getPlayerDataManager().getPlayerAction(p);
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerAction(p);
|
||||
playerData.setInKit(this);
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Lang.PREVIEWING_KIT.getConfigValue(showableName));
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Lang.PREVIEWING_KIT.getConfigValue(showableName));
|
||||
String guititle = Arconix.pl().getApi().format().formatTitle(Lang.PREVIEW_TITLE.getConfigValue(showableName));
|
||||
if (title != null) {
|
||||
guititle = Lang.PREVIEW_TITLE.getConfigValue(Arconix.pl().getApi().format().formatText(title, true));
|
||||
@ -226,7 +229,7 @@ public class Kit {
|
||||
buyable = true;
|
||||
}
|
||||
int min = 0;
|
||||
if (UltimateKits.getInstance().getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
if (plugin.getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
min = 9;
|
||||
if (!buyable) {
|
||||
min = min + 9;
|
||||
@ -247,8 +250,8 @@ public class Kit {
|
||||
|
||||
|
||||
int num = 0;
|
||||
if (!UltimateKits.getInstance().getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
ItemStack exit = new ItemStack(Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Exit Icon")), 1);
|
||||
if (!plugin.getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
ItemStack exit = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.Exit Icon")), 1);
|
||||
ItemMeta exitmeta = exit.getItemMeta();
|
||||
exitmeta.setDisplayName(Lang.EXIT.getConfigValue());
|
||||
exit.setItemMeta(exitmeta);
|
||||
@ -286,11 +289,11 @@ public class Kit {
|
||||
}
|
||||
|
||||
if (buyable) {
|
||||
ItemStack link = new ItemStack(Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Buy Icon")), 1);
|
||||
ItemStack link = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.Buy Icon")), 1);
|
||||
ItemMeta linkmeta = link.getItemMeta();
|
||||
linkmeta.setDisplayName(Lang.BUYNOW.getConfigValue());
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
if (hasPermission(p) && UltimateKits.getInstance().getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
|
||||
if (hasPermission(p) && plugin.getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
|
||||
lore.add(Lang.CLICKECO.getConfigValue("0"));
|
||||
if (p.isOp()) {
|
||||
lore.add("");
|
||||
@ -314,7 +317,7 @@ public class Kit {
|
||||
}
|
||||
|
||||
for (ItemStack is : list) {
|
||||
if (!UltimateKits.getInstance().getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
if (!plugin.getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
if (num == 17)
|
||||
num++;
|
||||
if (num == (max - 18))
|
||||
@ -347,13 +350,13 @@ public class Kit {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!UltimateKits.getInstance().getConfig().getBoolean("Main.Dont Preview Commands In Kits") || is.getType() != Material.PAPER || !is.getItemMeta().hasDisplayName() || !is.getItemMeta().getDisplayName().equals(Lang.COMMAND.getConfigValue())) {
|
||||
if (!plugin.getConfig().getBoolean("Main.Dont Preview Commands In Kits") || is.getType() != Material.PAPER || !is.getItemMeta().hasDisplayName() || !is.getItemMeta().getDisplayName().equals(Lang.COMMAND.getConfigValue())) {
|
||||
i.setItem(num, is);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
if (back && !UltimateKits.getInstance().getConfig().getBoolean("Interfaces.Do Not Use Glass Borders")) {
|
||||
if (back && !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");
|
||||
@ -415,7 +418,7 @@ public class Kit {
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
try {
|
||||
for (KitItem item : getContents()) {
|
||||
if ((!item.getSerialized().startsWith("/") && !item.getSerialized().startsWith(UltimateKits.getInstance().getConfig().getString("Main.Currency Symbol"))) || commands) { //ToDO: I doubt this is correct.
|
||||
if ((!item.getSerialized().startsWith("/") && !item.getSerialized().startsWith(plugin.getConfig().getString("Main.Currency Symbol"))) || commands) { //ToDO: I doubt this is correct.
|
||||
ItemStack stack = moveable ? item.getMoveableItem() : item.getItem();
|
||||
|
||||
ItemStack fin = stack;
|
||||
@ -483,8 +486,8 @@ public class Kit {
|
||||
amtToGive --;
|
||||
|
||||
if (kitAnimation != KitAnimation.NONE) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(),
|
||||
() -> new CrateAnimateTask(UltimateKits.getInstance(), player, this, item.getItem()), 210 * num);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
() -> new CrateAnimateTask(plugin, player, this, item.getItem()), 210 * num);
|
||||
} else {
|
||||
Map<Integer, ItemStack> overfilled = player.getInventory().addItem(item.getItem());
|
||||
for (ItemStack item2 : overfilled.values()) {
|
||||
@ -495,9 +498,9 @@ public class Kit {
|
||||
}
|
||||
}
|
||||
if (kitAnimation != KitAnimation.NONE) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(),
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
() -> {
|
||||
UltimateKits.getInstance().getPlayerDataManager().getPlayerAction(player).setInCrate(false);
|
||||
plugin.getPlayerDataManager().getPlayerAction(player).setInCrate(false);
|
||||
player.closeInventory();
|
||||
}, (210 * num) + 20);
|
||||
}
|
||||
@ -509,12 +512,12 @@ public class Kit {
|
||||
}
|
||||
|
||||
public void updateDelay(Player player) {
|
||||
UltimateKits.getInstance().getDataFile().getConfig().set("Kits." + name + ".delays." + player.getUniqueId().toString(), System.currentTimeMillis());
|
||||
plugin.getDataFile().getConfig().set("Kits." + name + ".delays." + player.getUniqueId().toString(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public Long getNextUse(Player player) {
|
||||
String configSectionPlayer = "Kits." + name + ".delays." + player.getUniqueId().toString();
|
||||
FileConfiguration config = UltimateKits.getInstance().getDataFile().getConfig();
|
||||
FileConfiguration config = plugin.getDataFile().getConfig();
|
||||
|
||||
if (!config.contains(configSectionPlayer)) {
|
||||
return 0L;
|
||||
@ -531,7 +534,7 @@ public class Kit {
|
||||
try {
|
||||
|
||||
double cost = price;
|
||||
if (hasPermission(p) && UltimateKits.getInstance().getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
|
||||
if (hasPermission(p) && plugin.getConfig().getBoolean("Main.Allow Players To Receive Kits For Free If They Have Permission")) {
|
||||
cost = 0;
|
||||
}
|
||||
Inventory i = Bukkit.createInventory(null, 27, Arconix.pl().getApi().format().formatTitle(Lang.GUI_TITLE_YESNO.getConfigValue(cost)));
|
||||
@ -567,12 +570,12 @@ public class Kit {
|
||||
i.setItem(25, Methods.getBackgroundGlass(true));
|
||||
i.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
ItemStack item2 = new ItemStack(Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Buy Icon")), 1);
|
||||
ItemStack item2 = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.Buy Icon")), 1);
|
||||
ItemMeta itemmeta2 = item2.getItemMeta();
|
||||
itemmeta2.setDisplayName(Lang.YES_GUI.getConfigValue());
|
||||
item2.setItemMeta(itemmeta2);
|
||||
|
||||
ItemStack item3 = new ItemStack(Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Exit Icon")), 1);
|
||||
ItemStack item3 = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.Exit Icon")), 1);
|
||||
ItemMeta itemmeta3 = item3.getItemMeta();
|
||||
itemmeta3.setDisplayName(Lang.NO_GUI.getConfigValue());
|
||||
item3.setItemMeta(itemmeta3);
|
||||
@ -581,8 +584,8 @@ public class Kit {
|
||||
i.setItem(11, item2);
|
||||
i.setItem(15, item3);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(), () -> {
|
||||
PlayerData playerData = UltimateKits.getInstance().getPlayerDataManager().getPlayerAction(p);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerAction(p);
|
||||
playerData.setInKit(this);
|
||||
playerData.setGuiLocation(PlayerData.GUILocation.BUY_FINAL);
|
||||
}, 1);
|
||||
@ -593,23 +596,23 @@ public class Kit {
|
||||
|
||||
public void buyWithEconomy(Player p) {
|
||||
try {
|
||||
if (UltimateKits.getInstance().getServer().getPluginManager().getPlugin("Vault") == null) return;
|
||||
RegisteredServiceProvider<Economy> rsp = UltimateKits.getInstance().getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (plugin.getServer().getPluginManager().getPlugin("Vault") == null) return;
|
||||
RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
|
||||
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
|
||||
if (!econ.has(p, price) && !hasPermission(p)) {
|
||||
if (!hasPermission(p))
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NO_PERM.getConfigValue(showableName)));
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NO_PERM.getConfigValue(showableName)));
|
||||
else
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.CANNOT_AFFORD.getConfigValue(showableName)));
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.CANNOT_AFFORD.getConfigValue(showableName)));
|
||||
return;
|
||||
}
|
||||
if (this.delay > 0) {
|
||||
|
||||
if (getNextUse(p) == -1) {
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.NOT_TWICE.getConfigValue(showableName)));
|
||||
} else if (getNextUse(p) != 0) {
|
||||
p.sendMessage(UltimateKits.getInstance().references.getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(p)))));
|
||||
p.sendMessage(plugin.getReferences().getPrefix() + Arconix.pl().getApi().format().formatText(Lang.DELAY.getConfigValue(Arconix.pl().getApi().format().readableTime(getNextUse(p)))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class KitBlockData {
|
||||
setShowHologram(false);
|
||||
setDisplayingItems(false);
|
||||
setHasParticles(false);
|
||||
UltimateKits.getInstance().displayitem.displayItem(this);
|
||||
UltimateKits.getInstance().getDisplayItemHandler().displayItem(this);
|
||||
UltimateKits.getInstance().getHologramHandler().updateHolograms();
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,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.references.getPrefix() + TextComponent.formatText(Lang.CRATE_WON.getConfigValue(WordUtils.capitalize(give.getType().name().toLowerCase().replace("_", " ")))));
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + TextComponent.formatText(Lang.CRATE_WON.getConfigValue(WordUtils.capitalize(give.getType().name().toLowerCase().replace("_", " ")))));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> finish(), 50);
|
||||
}
|
||||
done = true;
|
||||
|
Loading…
Reference in New Issue
Block a user