2.7.0 #8

Merged
JaTiTV merged 16 commits from 2.7.0 into main 2022-04-28 17:55:34 +00:00
28 changed files with 850 additions and 575 deletions
Showing only changes of commit f2a666773f - Show all commits

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.6.10_Snapshot-3</version>
<version>2.7.0_Snapshot-1</version>
<packaging>jar</packaging>
<name>CommandGUI</name>

View File

@ -1,34 +0,0 @@
package de.jatitv.commandguiv2.Spigot.Listener;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.HashMap;
public class ConfigChat implements Listener {
public static HashMap<Player, String> EditChat = new HashMap<>();
@EventHandler
public void onChat(AsyncPlayerChatEvent playerChatEvent) {
Player player = playerChatEvent.getPlayer();
if (EditChat.containsKey(player)) {
if (playerChatEvent.getMessage().equals("cancel")) {
//player.sendMessage(DefaultValue.SettingsGUIchatIsCanceled.replace("[setting]", EditChat.get(player)));
} else {
for (Object gui : Main.guiHashMap.values()) {
for (Slot slot : gui.GUI_Slots) {
if (slot.configOptionPath.equals(EditChat.get(player))) {
}
}
}
}
}
}
}

View File

@ -1,11 +1,12 @@
package de.jatitv.commandguiv2.Spigot.Listener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import de.jatitv.commandguiv2.Spigot.system.Bungee_Sender_Reciver;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.Main;
@ -42,58 +43,60 @@ public class GUI_Listener implements Listener {
JavaPlugin plugin = Main.plugin;
if (e.getInventory() == null) return;
if (e.getCurrentItem() == null) return;
for (Object gui : Main.guiHashMap.values()) {
for (Gui gui : Main.guiHashMap.values()) {
if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name))
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) {
e.setCancelled(true);
for (Slot slot : gui.GUI_Slots) {
for (Slot slot : gui.slots) {
Function function = Main.functionHashMap.get(slot.function);
if (e.getSlot() != slot.slot) continue;
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() || e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() || e.getCurrentItem().getType() == Material.valueOf(slot.item.toUpperCase().replace(".", "_"))) {
if (!slot.perm
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1))
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1) + ".use")
|| player.hasPermission("commandgui.admin")) {
if (!slot.enable) continue;
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.name))) continue;
if (slot.cost_Enable) {
if (slot.command_Enable || slot.message_Enable || slot.openGUI_Enable || slot.serverChange) {
if (!Vault.buy(prefix, player, slot.price)) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
player.sendMessage(SelectMessages.No_money);
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
} else {
player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.name))
.replace("[price]", slot.price + " " + SelectConfig.Currency));
execute(slot, player, e, gui);
}
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() ||
e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() ||
e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) {
if (slot.permission || !player.hasPermission(slot.permissionToUse)) {
player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name))
.replace("[perm]", slot.permissionToUse));
continue;
}
if (!slot.enable) continue;
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, function.name))) continue;
if (function.cost_Enable) {
if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) {
if (!Vault.buy(prefix, player, function.price)) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
player.sendMessage(SelectMessages.No_money);
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
} else {
player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
.replace("[price]", function.price + " " + SelectConfig.Currency));
execute(function, slot, player, e, gui);
}
} else execute(slot, player, e, gui);
} else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.name))
.replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1)));
}
} else execute(function, slot, player, e, gui);
}
}
}
}
}
private static void execute(Slot slot, Player player, InventoryClickEvent e, Object gui) {
if (slot.togglePermission) togglePerm(slot, player);
if (slot.toggleUseItem) toggleUseItem(player);
if (slot.command_Enable) command(slot, player);
if (slot.openGUI_Enable) openGUI(slot, player);
if (slot.message_Enable) message(slot, player);
if (slot.serverChange) serverChange(slot, player);
if (slot.setConfigEnable) setConfig(slot, player, e);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(slot, player, gui);
private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) {
if (function.togglePermission) togglePerm(function, player);
if (function.toggleUseItem) toggleUseItem(player);
if (function.command_Enable) command(function, player);
if (function.openGUI_Enable) openGUI(function, player);
if (function.message_Enable) message(function, player);
if (function.serverChange) serverChange(function, player);
if (function.setConfigEnable) setConfig(function, player, e);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(function, slot, player, gui);
}
private static void command(Slot slot, Player player) {
private static void command(Function slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
@ -123,7 +126,7 @@ public class GUI_Listener implements Listener {
}.runTaskLater(plugin, 2L);
}
private static void openGUI(Slot slot, Player player) {
private static void openGUI(Function slot, Player player) {
player.closeInventory();
new BukkitRunnable() {
@Override
@ -133,7 +136,7 @@ public class GUI_Listener implements Listener {
}.runTaskLater(plugin, 1L);
}
private static void message(Slot slot, Player player) {
private static void message(Function slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
@ -153,7 +156,7 @@ public class GUI_Listener implements Listener {
}
}
private static void serverChange(Slot slot, Player player) {
private static void serverChange(Function slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
@ -169,7 +172,7 @@ public class GUI_Listener implements Listener {
}.runTaskLater(Main.plugin, 20L);
}
private static void setConfig(Slot slot, Player player, InventoryClickEvent e) {
private static void setConfig(Function slot, Player player, InventoryClickEvent e) {
File config = new File(slot.configFilePath);
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
@ -219,22 +222,22 @@ public class GUI_Listener implements Listener {
}.runTaskLater(plugin, 1L);
}
private static void sound(Slot slot, Player player, Object gui) {
if (slot.customSound_Enable) {
if (!slot.customSound_NoSound) {
private static void sound(Function function, Slot slot, Player player, Gui gui) {
if (function.customSound_Enable) {
if (!function.customSound_NoSound) {
try {
player.playSound(player.getLocation(), Sound.valueOf(slot.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + slot.customSound_Sound));
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound));
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
}
}
}
private static void togglePerm(Slot slot, Player player) {
private static void togglePerm(Function slot, Player player) {
if (player.hasPermission(slot.togglePermissionPerm)) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm));
} else

View File

@ -2,14 +2,12 @@ package de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener;
import de.jatitv.commandguiv2.Spigot.Listener.ItemChange;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
import de.jatitv.commandguiv2.api.CGuiAPI;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;

View File

@ -1,9 +1,9 @@
package de.jatitv.commandguiv2.Spigot;
//s<ds
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.system.Load;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
@ -43,9 +43,11 @@ public final class Main extends JavaPlugin {
public static Boolean LuckyBox = false;
public static Boolean PlugManGUI = false;
public static HashMap<String, Object> guiHashMap = new HashMap<>();
public static HashMap<String, Gui> guiHashMap = new HashMap<>();
public static ArrayList<String> allAliases = new ArrayList<>();
public static HashMap<String, Function> functionHashMap = new HashMap<>();
@Override
public void onEnable() {
plugins = Arrays.asList(getServer().getPluginManager().getPlugins());

View File

@ -1,115 +0,0 @@
package de.jatitv.commandguiv2.Spigot.Objekte;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class Obj_Select {
public static void onSelect() {
Main.guiHashMap.clear();
Main.allAliases.clear();
File f = new File(Main.getPath() + "/GUIs/");
File[] fileArray = f.listFiles();
for (File config_gui : fileArray) {
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (sub.equals(".yml")) {
Main.allAliases.add(config_gui.getName().replace(".yml", ""));
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui);
Boolean GUI_Enable = yamlConfiguration_gui.getBoolean("GUI.Enable");
Integer GUI_Lines = yamlConfiguration_gui.getInt("GUI.Lines");
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
yamlConfiguration_gui.set("GUI.Lines", 6);
}
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
yamlConfiguration_gui.set("GUI.Lines", 1);
}
String GUI_Name = yamlConfiguration_gui.getString("GUI.Name");
Boolean GUI_FillItem_Enable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
String GUI_FillItem_Item;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
GUI_FillItem_Item = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneCollor");
} else GUI_FillItem_Item = yamlConfiguration_gui.getString("GUI.FillItem.Item");
Boolean Command_Alias_Enable = yamlConfiguration_gui.getBoolean("Command.Alias");
Boolean Command_Permission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
ArrayList<Slot> slots = new ArrayList<>();
for (String key : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
Slot slot = new Slot(yamlConfiguration_gui.getInt("Slots." + key + ".Slot") - 1,
yamlConfiguration_gui.getBoolean("Slots." + key + ".Enable"),
// yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.Removable"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.Empty"),
yamlConfiguration_gui.getInt("Slots." + key + ".Item.Amount"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.PlayerHead.Enable"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.PlayerHead.Base64.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".Item.PlayerHead.Base64.Base64Value"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.PlayerHead.PlayerWhoHasOpenedTheGUI"),
yamlConfiguration_gui.getString("Slots." + key + ".Item.PlayerHead.PlayerName"),
yamlConfiguration_gui.getString("Slots." + key + ".Item.Material"),
yamlConfiguration_gui.getString("Slots." + key + ".Item.Name"),
yamlConfiguration_gui.getStringList("Slots." + key + ".Item.Lore"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".CustomSound.Enable"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".CustomSound.NoSound"),
yamlConfiguration_gui.getString("Slots." + key + ".CustomSound.Sound"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Cost.Enable"),
yamlConfiguration_gui.getDouble("Slots." + key + ".Cost.Price"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Command.Enable"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Command.BungeeCommand"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Command.CommandAsConsole"),
yamlConfiguration_gui.getStringList("Slots." + key + ".Command.Command"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".ServerChange.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".ServerChange.Server"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".OpenGUI.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".OpenGUI.GUI"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Toggle.Permission.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".Toggle.Permission.Permission"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Toggle.UseItem.Enable"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Message.Enable"),
yamlConfiguration_gui.getStringList("Slots." + key + ".Message.Message"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.File.Path"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Option.Path"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Option.Premat"),
// yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Value.ChatInput"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Value.LeftClick.String"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Value.LeftClick.Boolean"),
yamlConfiguration_gui.getInt("Slots." + key + ".SetConfig.Value.LeftClick.Integer"),
yamlConfiguration_gui.getDouble("Slots." + key + ".SetConfig.Value.LeftClick.Double"),
yamlConfiguration_gui.getStringList("Slots." + key + ".SetConfig.Value.LeftClick.List"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Value.RightClick.String"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Value.RightClick.Boolean"),
yamlConfiguration_gui.getInt("Slots." + key + ".SetConfig.Value.RightClick.Integer"),
yamlConfiguration_gui.getDouble("Slots." + key + ".SetConfig.Value.RightClick.Double"),
yamlConfiguration_gui.getStringList("Slots." + key + ".SetConfig.RightClick.Value.List"),
yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.PluginReload.Command"));
slots.add(slot);
}
Object objekt = new Object(GUI_Enable, GUI_Lines, GUI_Name, GUI_FillItem_Enable, GUI_FillItem_Item,
config_gui.getName().replace(".yml", ""), Command_Alias_Enable, Command_Permission, slots);
Main.guiHashMap.put(config_gui.getName().replace(".yml", ""), objekt);
CmdExecuter_GUITab.arg1.put(config_gui.getName().replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", ""));
try {
yamlConfiguration_gui.save(config_gui);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -55,7 +55,8 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
} else sender.sendMessage(SelectMessages.OnlyForPlayer);
}
}
} else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui-item").replace("[perm]", "commandgui.useitem.toggle"));
} else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui-item")
.replace("[perm]", "commandgui.useitem.toggle"));
return false;
}

View File

@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.Debug;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.commands.Tab;
@ -56,7 +56,7 @@ public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter {
break;
case "createdefaultgui":
if (sender.hasPermission("commandgui.admin")) {
DefaultGUICreate.configCreate();
CreateGUI.configCreate();
sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "/GUIs/default.yml"));
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));

View File

@ -2,8 +2,8 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Obj_Select;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.Give_UseItem;
@ -215,7 +215,7 @@ public class Commands {
public static void gui(Player player) {
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, SelectConfig.DefaultGUI);
@ -230,7 +230,7 @@ public class Commands {
public static void gui(Player player, String arg) {
if (Main.guiHashMap.containsKey(arg)) {
Object gui = Main.guiHashMap.get(arg);
Gui gui = Main.guiHashMap.get(arg);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, arg);

View File

@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -14,7 +14,7 @@ public class Help {
public static void sendHelp(CommandSender sender, String Prefix) {
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
if (sender.hasPermission("commandgui.command")) {
Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.GUI_Name)));
for (String alias : Main.allAliases) {
if (Main.guiHashMap.get(alias).GUI_Enable || sender.hasPermission("commandgui.bypass")) {

View File

@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
@ -23,7 +23,7 @@ public class RegisterCommand extends Command {
if (sender instanceof Player) {
Player player = (Player) sender;
Object gui = Main.guiHashMap.get(alias);
Gui gui = Main.guiHashMap.get(alias);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, alias);

View File

@ -1,185 +0,0 @@
package de.jatitv.commandguiv2.Spigot.config;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class DefaultGUICreate {
public static void configCreate() {
Long long_ = Long.valueOf(System.currentTimeMillis());
send.console(Main.prefix + " §4Default GUI file (GUIs/default.yml) is loaded...");
File config = new File(Main.getPath(), "GUIs/default.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
set("GUI.Enable", true, yamlConfiguration);
set("GUI.Lines", 1, yamlConfiguration);
set("GUI.Name", "&5default &9GUI", yamlConfiguration);
set("GUI.FillItem.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("GUI.FillItem.GlassPaneCollor", 15, yamlConfiguration);
} else set("GUI.FillItem.Item", "BLACK_STAINED_GLASS_PANE", yamlConfiguration);
set("Command.Alias", true, yamlConfiguration);
set("Command.Permission.Required", true, yamlConfiguration);
set("Slots.SupportDiscord.Slot", 4, yamlConfiguration);
set("Slots.SupportDiscord.Enable", true, yamlConfiguration);
set("Slots.SupportDiscord.Item.Empty", false, yamlConfiguration);
set("Slots.SupportDiscord.Item.Amount", 1, yamlConfiguration);
if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
set("Slots.SupportDiscord.Item.PlayerHead.Enable", true, yamlConfiguration);
set("Slots.SupportDiscord.Item.PlayerHead.Base64.Enable", true, yamlConfiguration);
set("Slots.SupportDiscord.Item.PlayerHead.Base64.Base64Value", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19", yamlConfiguration);
set("Slots.SupportDiscord.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration);
set("Slots.SupportDiscord.Item.PlayerHead.PlayerName", "", yamlConfiguration);
}
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("Slots.SupportDiscord.Item.Material", "TNT", yamlConfiguration);
} else set("Slots.SupportDiscord.Item.Material", "", yamlConfiguration);
set("Slots.SupportDiscord.Item.Name", "&3Support Discord", yamlConfiguration);
set("Slots.SupportDiscord.Item.Lore", Arrays.asList("&8-----------------", "&bIf you need help setting up the plugin,", "&bfeel free to contact me on the Suport Discord.",
"&8-----------------", "&eIf you find any errors or bugs,", "&eplease contact me so I can fix them.", "&8-----------------", "&5Discord: §7http://dc.t2code.net"),
yamlConfiguration);
set("Slots.SupportDiscord.CustomSound.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.CustomSound.NoSound", false, yamlConfiguration);
set("Slots.SupportDiscord.CustomSound.Sound", "", yamlConfiguration);
set("Slots.SupportDiscord.Cost.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.Cost.Price", 0.0, yamlConfiguration);
set("Slots.SupportDiscord.Command.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.Command.BungeeCommand", false, yamlConfiguration);
set("Slots.SupportDiscord.Command.CommandAsConsole", false, yamlConfiguration);
set("Slots.SupportDiscord.Command.Command", Arrays.asList(), yamlConfiguration);
set("Slots.SupportDiscord.ServerChange.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.ServerChange.Server", "", yamlConfiguration);
set("Slots.SupportDiscord.OpenGUI.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.OpenGUI.GUI", "", yamlConfiguration);
set("Slots.SupportDiscord.Toggle.Permission.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.Toggle.Permission.Permission", "", yamlConfiguration);
set("Slots.SupportDiscord.Toggle.UseItem.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.Message.Enable", true, yamlConfiguration);
set("Slots.SupportDiscord.Message.Message", Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"), yamlConfiguration);
set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.File.Path", "", yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Option.Path", "", yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Option.Premat", "String", yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.LeftClick.String", "", yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Boolean", false, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Integer", 0, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Double", 0.0, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.LeftClick.List", Arrays.asList(), yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.RightClick.String", "", yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.RightClick.Boolean", false, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.RightClick.Integer", 0, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.RightClick.Double", 0.0, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.Value.RightClick.List", Arrays.asList(), yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.PluginReload.Enable", false, yamlConfiguration);
set("Slots.SupportDiscord.SetConfig.PluginReload.Command", "", yamlConfiguration);
set("Slots.UseItem.Slot", 6, yamlConfiguration);
set("Slots.UseItem.Enable", true, yamlConfiguration);
set("Slots.UseItem.Item.Empty", false, yamlConfiguration);
set("Slots.UseItem.Item.Amount", 1, yamlConfiguration);
if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
set("Slots.UseItem.Item.PlayerHead.Enable", false, yamlConfiguration);
set("Slots.UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration);
set("Slots.UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration);
set("Slots.UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration);
set("Slots.UseItem.Item.PlayerHead.PlayerName", "", yamlConfiguration);
}
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("Slots.UseItem.Item.Material", "", yamlConfiguration);
} else set("Slots.UseItem.Item.Material", "", yamlConfiguration);
set("Slots.UseItem.Item.Name", "&6Toggle UseItem", yamlConfiguration);
set("Slots.UseItem.Item.Lore", Arrays.asList("&bYou currently have the UseItem set to: %commandgui_useitem%"),
yamlConfiguration);
set("Slots.UseItem.CustomSound.Enable", false, yamlConfiguration);
set("Slots.UseItem.CustomSound.NoSound", false, yamlConfiguration);
set("Slots.UseItem.CustomSound.Sound", "", yamlConfiguration);
set("Slots.UseItem.Cost.Enable", false, yamlConfiguration);
set("Slots.UseItem.Cost.Price", 0.0, yamlConfiguration);
set("Slots.UseItem.Command.Enable", false, yamlConfiguration);
set("Slots.UseItem.Command.BungeeCommand", false, yamlConfiguration);
set("Slots.UseItem.Command.CommandAsConsole", false, yamlConfiguration);
set("Slots.UseItem.Command.Command", Arrays.asList(), yamlConfiguration);
set("Slots.UseItem.ServerChange.Enable", false, yamlConfiguration);
set("Slots.UseItem.ServerChange.Server", "", yamlConfiguration);
set("Slots.UseItem.OpenGUI.Enable", false, yamlConfiguration);
set("Slots.UseItem.OpenGUI.GUI", "", yamlConfiguration);
set("Slots.UseItem.Toggle.Permission.Enable", false, yamlConfiguration);
set("Slots.UseItem.Toggle.Permission.Permission", "", yamlConfiguration);
set("Slots.UseItem.Toggle.UseItem.Enable", true, yamlConfiguration);
set("Slots.UseItem.Message.Enable", true, yamlConfiguration);
set("Slots.UseItem.Message.Message", Arrays.asList("&bYour UseItem was set to: %commandgui_useitem%&b."), yamlConfiguration);
set("Slots.UseItem.Permission.Required", false, yamlConfiguration);
set("Slots.UseItem.SetConfig.Enable", false, yamlConfiguration);
set("Slots.UseItem.SetConfig.File.Path", "", yamlConfiguration);
set("Slots.UseItem.SetConfig.Option.Path", "", yamlConfiguration);
set("Slots.UseItem.SetConfig.Option.Premat", "String", yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.LeftClick.String", "", yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.LeftClick.Boolean", false, yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.LeftClick.Integer", 0, yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.LeftClick.Double", 0.0, yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.LeftClick.List", Arrays.asList(), yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.RightClick.String", "", yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.RightClick.Boolean", false, yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.RightClick.Integer", 0, yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.RightClick.Double", 0.0, yamlConfiguration);
set("Slots.UseItem.SetConfig.Value.RightClick.List", Arrays.asList(), yamlConfiguration);
set("Slots.UseItem.SetConfig.PluginReload.Enable", false, yamlConfiguration);
set("Slots.UseItem.SetConfig.PluginReload.Command", "", yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
private static void set(String path, String value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Integer value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Boolean value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, List value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Double value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
}

View File

@ -15,10 +15,8 @@ import java.util.Arrays;
public class ConfigCreate {
public static Integer ConfigVersion = 4;
public static void configCreate() {
Long long_ = Long.valueOf(System.currentTimeMillis());
long long_ = System.currentTimeMillis();
if (new File(Main.getPath(), "config.yml").exists()) {
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Main.prefix + " §4config.yml are created...");
@ -26,15 +24,8 @@ public class ConfigCreate {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.getInt("ConfigVersion") < ConfigVersion && new File(Main.getPath(), "config.yml").exists()) {
send.console(Util.getPrefix() + " §4----------------------");
send.console(Util.getPrefix() + " ");
send.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
send.console(Util.getPrefix() + " ");
send.console(Util.getPrefix() + " §4----------------------");
}
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
yamlConfiguration.set("ConfigVersion", ConfigVersion);
Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration);
Config.set("Plugin.Debug", false, yamlConfiguration);
@ -171,6 +162,6 @@ public class ConfigCreate {
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -1,22 +1,26 @@
package de.jatitv.commandguiv2.Spigot.config.config;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class SelectConfig {
private static final File config = new File(Main.getPath(), "config.yml");
private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
public static Boolean DisableUpdateChecker;
public static Boolean UpdateCheckOnJoin;
public static Boolean Debug;
@ -113,8 +117,17 @@ public class SelectConfig {
public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
send.console(Util.getPrefix() + " §4----------------------");
send.console(Util.getPrefix() + " ");
send.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
send.console(Util.getPrefix() + " ");
send.console(Util.getPrefix() + " §4----------------------");
if (yamlConfiguration.getInt("ConfigVersion") < 5) {
ConfigConverterUnderV5.convert();
}
}
if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) {
DisableUpdateChecker = false;
@ -211,6 +224,7 @@ public class SelectConfig {
Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_"));
Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable");
Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_"));
setConfigVersion();
}
@ -333,4 +347,13 @@ public class SelectConfig {
}
}
private static void setConfigVersion() {
yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,176 @@
package de.jatitv.commandguiv2.Spigot.config.configConverter;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class ConfigConverterUnderV5 {
public static void convert() {
renameFolder();
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4Config conversion to the new config structure starts!");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
File f = new File(Main.getPath() + "/OldConfig/GUIs/Version4");
File[] fileArray = f.listFiles();
for (File configOld : fileArray) {
String sub = configOld.getName().substring(configOld.getName().length() - 4);
if (sub.equals(".yml")) {
YamlConfiguration yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
File config = new File(Main.getPath(), "GUIs/" + configOld.getName().replace(".yml", "") + ".yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
Boolean enable = yamlConfigurationOld.getBoolean("GUI.Enable");
Integer lines = yamlConfigurationOld.getInt("GUI.Lines");
String name = yamlConfigurationOld.getString("GUI.Name");
Boolean fillItemEnable = yamlConfigurationOld.getBoolean("GUI.FillItem.Enable");
String fillItem;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
fillItem = yamlConfigurationOld.getString("GUI.FillItem.GlassPaneColor");
} else fillItem = yamlConfigurationOld.getString("GUI.FillItem.Item");
Boolean alias = yamlConfigurationOld.getBoolean("Command.Alias");
Boolean aliasPerm = yamlConfigurationOld.getBoolean("Command.Permission.Required");
setNew(enable, lines, name, fillItemEnable, fillItem, alias, aliasPerm, yamlConfiguration);
for (String key : yamlConfigurationOld.getConfigurationSection("Slots").getKeys(false)) {
Integer slotNumber = yamlConfigurationOld.getInt("Slots." + key + ".Slot");
Boolean slotEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Enable");
Boolean permRequired = yamlConfigurationOld.getBoolean("Slots." + key + ".Permission.Required");
Boolean empty = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.Empty");
Integer itemAmount = yamlConfigurationOld.getInt("Slots." + key + ".Item.Amount");
Boolean playerHeadEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.PlayerHead.Enable");
Boolean base64Enable = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.PlayerHead.Base64.Enable");
String base64Value = yamlConfigurationOld.getString("Slots." + key + ".Item.PlayerHead.Base64.Base64Value");
Boolean playerWhoHasOpenedTheGUI = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
String playerName = yamlConfigurationOld.getString("Slots." + key + ".Item.PlayerHead.PlayerName");
String itemMaterial = yamlConfigurationOld.getString("Slots." + key + ".Item.Material");
String itemName = yamlConfigurationOld.getString("Slots." + key + ".Item.Name");
List<String> lore = yamlConfigurationOld.getStringList("Slots." + key + ".Item.Lore");
Boolean customSoundEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".CustomSound.Enable");
Boolean customSoundNoSound = yamlConfigurationOld.getBoolean("Slots." + key + ".CustomSound.NoSound");
String customSoundSound = yamlConfigurationOld.getString("Slots." + key + ".CustomSound.Sound");
Boolean costEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Cost.Enable");
Double price = yamlConfigurationOld.getDouble("Slots." + key + ".Cost.Price");
Boolean commandEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Command.Enable");
Boolean commandBungeeCommand = yamlConfigurationOld.getBoolean("Slots." + key + ".Command.BungeeCommand");
Boolean commandAsConsole = yamlConfigurationOld.getBoolean("Slots." + key + ".Command.CommandAsConsole");
List<String> command = yamlConfigurationOld.getStringList("Slots." + key + ".Command.Command");
Boolean serverChange = yamlConfigurationOld.getBoolean("Slots." + key + ".ServerChange.Enable");
String serverChangeServer = yamlConfigurationOld.getString("Slots." + key + ".ServerChange.Server");
Boolean openGUIEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".OpenGUI.Enable");
String openGUI = yamlConfigurationOld.getString("Slots." + key + ".OpenGUI.GUI");
Boolean togglePermission = yamlConfigurationOld.getBoolean("Slots." + key + ".Toggle.Permission.Enable");
String togglePermissionPerm = yamlConfigurationOld.getString("Slots." + key + ".Toggle.Permission.Permission");
Boolean toggleUseItem = yamlConfigurationOld.getBoolean("Slots." + key + ".Toggle.UseItem.Enable");
Boolean messageEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Message.Enable");
List<String> message = yamlConfigurationOld.getStringList("Slots." + key + ".Message.Message");
Boolean setConfigEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.Enable");
String configFilePath = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.File.Path");
String configOptionPath = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Option.Path");
String configOptionPremat = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Option.Premat");
// Boolean ConfigChatInput = ;
String configStringValueLeft = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Value.LeftClick.String");
Boolean configBooleanValueLeft = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.Value.LeftClick.Boolean");
Integer configIntegerValueLeft = yamlConfigurationOld.getInt("Slots." + key + ".SetConfig.Value.LeftClick.Integer");
Double configDoubleValueLeft = yamlConfigurationOld.getDouble("Slots." + key + ".SetConfig.Value.LeftClick.Double");
List<String> configListValueLeft = yamlConfigurationOld.getStringList("Slots." + key + ".SetConfig.Value.LeftClick.List");
String configStringValueRight = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Value.RightClick.String");
Boolean configBooleanValueRight = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.Value.RightClick.Boolean");
Integer configIntegerValueRight = yamlConfigurationOld.getInt("Slots." + key + ".SetConfig.Value.RightClick.Integer");
Double configDoubleValueRight = yamlConfigurationOld.getDouble("Slots." + key + ".SetConfig.Value.RightClick.Double");
List<String> configListValueRight = yamlConfigurationOld.getStringList("Slots." + key + ".SetConfig.RightClick.Value.List");
Boolean pluginReloadEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable");
String pluginReloadCommand = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.PluginReload.Command");
setNew(key, slotNumber, slotEnable, key, permRequired, yamlConfiguration);
CreateFunctions.createFunction(key, empty, itemAmount, playerHeadEnable, base64Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, itemMaterial, itemName, lore,
customSoundEnable, customSoundNoSound, customSoundSound, costEnable, price, commandEnable, commandBungeeCommand, commandAsConsole, command, serverChange,
serverChangeServer, openGUIEnable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, messageEnable, message, setConfigEnable, configFilePath,
configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft, configDoubleValueLeft, configListValueLeft,
configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, configListValueRight, pluginReloadEnable, pluginReloadCommand);
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
}
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4The conversion to the new config structure is completed!");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
}
private static void renameFolder() {
File dir = new File(Main.getPath() + "/GUIs");
File newDir = new File(Main.getPath() + "/OldConfig/GUIs/Version4");
try {
FileUtils.moveDirectory(dir, newDir);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void setNew(Boolean enable, Integer lines, String name, Boolean fillItemEnable, String fillItem, Boolean alias, Boolean aliasPerm, YamlConfiguration yamlConfiguration) {
set("GUI.Enable", enable, yamlConfiguration);
set("GUI.Lines", lines, yamlConfiguration);
set("GUI.Name", name, yamlConfiguration);
set("GUI.FillItem.Enable", fillItemEnable, yamlConfiguration);
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("GUI.FillItem.GlassPaneColor", fillItem, yamlConfiguration);
} else set("GUI.FillItem.Item", fillItem, yamlConfiguration);
set("Command.Alias", alias, yamlConfiguration);
set("Command.Permission.Required", aliasPerm, yamlConfiguration);
}
private static void setNew(String key, Integer slotNumber, Boolean slotEnable, String function, Boolean permRequired, YamlConfiguration yamlConfiguration) {
set("Slots." + key + ".Slot", slotNumber, yamlConfiguration);
set("Slots." + key + ".Enable", slotEnable, yamlConfiguration);
set("Slots." + key + ".Function", function, yamlConfiguration);
set("Slots." + key + ".Permission.Required", permRequired, yamlConfiguration);
set("Slots." + key + ".Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
set("Slots." + key + ".Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
}
private static void set(String path, String value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Integer value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Boolean value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
}

View File

@ -0,0 +1,146 @@
package de.jatitv.commandguiv2.Spigot.config.functions;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class CreateFunctions {
public static void create() {
createFunction("UseItem", false, 1, false, false, "", false, "", "",
"&6Toggle UseItem", Arrays.asList("&bYou currently have the UseItem set to: %commandgui_useitem%"), false, false,
"", false, 0.0, false, false, false, Arrays.asList(), false,
"", false, "", false, "", true, true,
Arrays.asList("&bYour UseItem was set to: %commandgui_useitem%&b."), false, "", "", "String",
"", false, 0, 0.0, Arrays.asList(), "", false,
0, 0.0, Arrays.asList(), false, "");
createFunction("SupportDiscord", false, 1, true, true, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19",
false, "", (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) ? "TNT" : "",
"&3Support Discord", Arrays.asList("&8-----------------", "&bIf you need help setting up the plugin,", "&bfeel free to contact me on the Suport Discord.",
"&8-----------------", "&eIf you find any errors or bugs,", "&eplease contact me so I can fix them.", "&8-----------------", "&5Discord: §7http://dc.t2code.net"),
false, false, "", false, 0.0, false, false,
false, Arrays.asList(), false, "", false, "", false, "",
false, true, Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"), false, "",
"", "String", "", false, 0, 0.0, Arrays.asList(),
"", false, 0, 0.0, Arrays.asList(), false, "");
}
public static void createFunction(String fileName, Boolean empty, Integer itemAmount, Boolean playerHeadEnable, Boolean base64Enable, String base64Value, Boolean playerWhoHasOpenedTheGUI,
String playerName, String itemMaterial, String name, List<String> lore, Boolean customSoundEnable, Boolean customSoundNoSound, String customSoundSound,
Boolean costEnable, Double price, Boolean commandEnable, Boolean commandBungeeCommand, Boolean commandAsConsole, List<String> command,
Boolean serverChange, String serverChangeServer, Boolean openGUIEnable, String openGUI, Boolean togglePermission, String togglePermissionPerm,
Boolean toggleUseItem, Boolean messageEnable, List<String> message, Boolean setConfigEnable, String configFilePath, String configOptionPath,
String configOptionPremat, String configStringValueLeft, Boolean configBooleanValueLeft, Integer configIntegerValueLeft, Double configDoubleValueLeft,
List<String> configListValueLeft, String configStringValueRight, Boolean configBooleanValueRight, Integer configIntegerValueRight, Double configDoubleValueRight,
List<String> configListValueRight, Boolean pluginReloadEnable, String pluginReloadCommand) {
long long_ = System.currentTimeMillis();
File config = new File(Main.getPath(), "Functions/" + fileName + ".yml");
int i = 1;
while (config.exists()) {
config = new File(Main.getPath(), "Functions/" + fileName + "-" + i + ".yml");
i++;
}
send.console(Main.prefix + " §4Function GUI file (Functions/" + config.getName() + ") is loaded...");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
set("Slots.Function.Item.Empty", empty, yamlConfiguration);
set("Slots.Function.Item.Amount", itemAmount, yamlConfiguration);
// if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
set("Slots.Function.Item.PlayerHead.Enable", playerHeadEnable, yamlConfiguration);
set("Slots.Function.Item.PlayerHead.Base64.Enable", base64Enable, yamlConfiguration);
set("Slots.Function.Item.PlayerHead.Base64.Base64Value", base64Value, yamlConfiguration);
set("Slots.Function.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", playerWhoHasOpenedTheGUI, yamlConfiguration);
set("Slots.Function.Item.PlayerHead.PlayerName", playerName, yamlConfiguration);
// }
set("Slots.Function.Item.Material", itemMaterial == null ? "" : itemMaterial, yamlConfiguration);
set("Slots.Function.Item.Name", name == null ? "" : name, yamlConfiguration);
set("Slots.Function.Item.Lore", lore, yamlConfiguration);
set("Slots.Function.CustomSound.Enable", customSoundEnable, yamlConfiguration);
set("Slots.Function.CustomSound.NoSound", customSoundNoSound, yamlConfiguration);
set("Slots.Function.CustomSound.Sound", customSoundSound == null ? "" : customSoundSound, yamlConfiguration);
set("Slots.Function.Cost.Enable", costEnable, yamlConfiguration);
set("Slots.Function.Cost.Price", price, yamlConfiguration);
set("Slots.Function.Command.Enable", commandEnable, yamlConfiguration);
set("Slots.Function.Command.BungeeCommand", commandBungeeCommand, yamlConfiguration);
set("Slots.Function.Command.CommandAsConsole", commandAsConsole, yamlConfiguration);
set("Slots.Function.Command.Command", command, yamlConfiguration);
set("Slots.Function.ServerChange.Enable", serverChange, yamlConfiguration);
set("Slots.Function.ServerChange.Server", serverChangeServer == null ? "" : serverChangeServer, yamlConfiguration);
set("Slots.Function.OpenGUI.Enable", openGUIEnable, yamlConfiguration);
set("Slots.Function.OpenGUI.GUI", openGUI == null ? "" : openGUI, yamlConfiguration);
set("Slots.Function.Toggle.Permission.Enable", togglePermission, yamlConfiguration);
set("Slots.Function.Toggle.Permission.Permission", togglePermissionPerm == null ? "" : togglePermissionPerm, yamlConfiguration);
set("Slots.Function.Toggle.UseItem.Enable", toggleUseItem, yamlConfiguration);
set("Slots.Function.Message.Enable", messageEnable, yamlConfiguration);
set("Slots.Function.Message.Message", message, yamlConfiguration);
set("Slots.Function.SetConfig.Enable", setConfigEnable, yamlConfiguration);
set("Slots.Function.SetConfig.File.Path", configFilePath == null ? "" : configFilePath, yamlConfiguration);
set("Slots.Function.SetConfig.Option.Path", configOptionPath == null ? "" : configOptionPath, yamlConfiguration);
set("Slots.Function.SetConfig.Option.Premat", configOptionPremat == null ? "" : configOptionPremat, yamlConfiguration);
set("Slots.Function.SetConfig.Value.LeftClick.String", configStringValueLeft == null ? "" : configStringValueLeft, yamlConfiguration);
set("Slots.Function.SetConfig.Value.LeftClick.Boolean", configBooleanValueLeft, yamlConfiguration);
set("Slots.Function.SetConfig.Value.LeftClick.Integer", configIntegerValueLeft, yamlConfiguration);
set("Slots.Function.SetConfig.Value.LeftClick.Double", configDoubleValueLeft, yamlConfiguration);
set("Slots.Function.SetConfig.Value.LeftClick.List", configListValueLeft, yamlConfiguration);
set("Slots.Function.SetConfig.Value.RightClick.String", configStringValueRight == null ? "" : configStringValueRight, yamlConfiguration);
set("Slots.Function.SetConfig.Value.RightClick.Boolean", configBooleanValueRight, yamlConfiguration);
set("Slots.Function.SetConfig.Value.RightClick.Integer", configIntegerValueRight, yamlConfiguration);
set("Slots.Function.SetConfig.Value.RightClick.Double", configDoubleValueRight, yamlConfiguration);
set("Slots.Function.SetConfig.Value.RightClick.List", configListValueRight, yamlConfiguration);
set("Slots.Function.SetConfig.PluginReload.Enable", pluginReloadEnable, yamlConfiguration);
set("Slots.Function.SetConfig.PluginReload.Command", pluginReloadCommand == null ? "" : pluginReloadCommand, yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2Function file (Functions/" + config.getName() + ") was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static void set(String path, String value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Integer value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Boolean value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, List value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Double value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
}

View File

@ -0,0 +1,72 @@
package de.jatitv.commandguiv2.Spigot.config.gui;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class CreateGUI {
public static void configCreate() {
long long_ = System.currentTimeMillis();
send.console(Main.prefix + " §4Default GUI file (GUIs/default.yml) is loaded...");
File config = new File(Main.getPath(), "GUIs/default.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
set("GUI.Enable", true, yamlConfiguration);
set("GUI.Lines", 1, yamlConfiguration);
set("GUI.Name", "&5default &9GUI", yamlConfiguration);
set("GUI.FillItem.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("GUI.FillItem.GlassPaneColor", 15, yamlConfiguration);
} else set("GUI.FillItem.Item", "BLACK_STAINED_GLASS_PANE", yamlConfiguration);
set("Command.Alias", true, yamlConfiguration);
set("Command.Permission.Required", true, yamlConfiguration);
set("Slots.SupportDiscord.Slot", 4, yamlConfiguration);
set("Slots.SupportDiscord.Enable", true, yamlConfiguration);
set("Slots.SupportDiscord.Function", "SupportDiscord", yamlConfiguration);
set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration);
set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
set("Slots.UseItem.Slot", 6, yamlConfiguration);
set("Slots.UseItem.Enable", true, yamlConfiguration);
set("Slots.UseItem.Function", "UseItem", yamlConfiguration);
set("Slots.UseItem.Permission.Required", false, yamlConfiguration);
set("Slots.UseItem.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
set("Slots.UseItem.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static void set(String path, String value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Integer value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Boolean value, YamlConfiguration config) {
if (!config.contains(path)) {
config.set(path, value);
}
}
}

View File

@ -3,12 +3,11 @@ package de.jatitv.commandguiv2.Spigot.gui;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.Material;
@ -25,34 +24,34 @@ public class GuiBuilder {
private static String prefix = Util.getPrefix();
protected static void item(Slot slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(slot.item.toUpperCase().replace(".", "_")));
protected static void item(Function function, Integer slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(function.item.toUpperCase().replace(".", "_")));
ItemMeta itemMeta = item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, slot);
setDisplayNameAndLore(itemMeta, player, function);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
if (function.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
inventory.setItem(slot, item);
}
protected static void item(String material, Slot slot, Player player, Inventory inventory) {
protected static void item(String material, Function function,Integer slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(material));
ItemMeta itemMeta = item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, slot);
setDisplayNameAndLore(itemMeta, player, function);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
if (function.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
inventory.setItem(slot, item);
}
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Slot slot) {
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Function slot) {
if (Main.PaPi) {
itemMeta.setDisplayName(Replace.replace(prefix, player, slot.name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, player, slot.lore, slot.price + " " + SelectConfig.Currency));
@ -62,18 +61,18 @@ public class GuiBuilder {
}
}
protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) {
protected static void base64(String base64Value, Function function, Integer slot, Player player, Inventory inventory) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setBase64(itemMeta, base64Value);
setDisplayNameAndLore(itemMeta, player, slot);
setDisplayNameAndLore(itemMeta, player, function);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
if (function.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
inventory.setItem(slot, item);
}
private static void setBase64(ItemMeta itemMeta, String base64Value) {
@ -89,25 +88,25 @@ public class GuiBuilder {
}
}
protected static void base64(Slot slot, Player player, Inventory inventory) {
base64(slot.base64Value, slot, player, inventory);
protected static void base64(Function function,Integer slot, Player player, Inventory inventory) {
base64(function.base64Value, function,slot, player, inventory);
}
protected static void playerHead(Slot slot, Player player, Inventory inventory, String skullName) {
protected static void playerHead(Function function, Integer slot,Player player, Inventory inventory, String skullName) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, slot);
setDisplayNameAndLore(itemMeta, player, function);
itemMeta.setOwner(skullName);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
if (function.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
inventory.setItem(slot, item);
}
public static void fillItem(Inventory inventory, Object gui) {
public static void fillItem(Inventory inventory, Gui gui) {
ItemStack glass;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item));

View File

@ -3,10 +3,11 @@ package de.jatitv.commandguiv2.Spigot.gui;
import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import de.jatitv.commandguiv2.Util;
import io.github.solyze.plugmangui.inventories.PluginListGUI;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -19,7 +20,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
public class OpenGUI {
@ -27,7 +27,7 @@ public class OpenGUI {
private static String prefix = Util.getPrefix();
public static void openGUI(Player player, String guiString) {
Object gui = Main.guiHashMap.get(guiString);
Gui gui = Main.guiHashMap.get(guiString);
Long long_ = Long.valueOf(System.currentTimeMillis());
switch (guiString) {
//case "plugin.PlotSquaredGUI":
@ -68,57 +68,57 @@ public class OpenGUI {
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
Inventory inventory;
if (Main.PaPi) {
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name)));
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name)));
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name)));
if (gui.GUI_FillItem_Enable) {
GuiBuilder.fillItem(inventory, gui);
}
for (Slot slot : gui.GUI_Slots) {
if (!slot.perm
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1))
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1) + ".see")
|| player.hasPermission("commandgui.admin")) {
if (slot.enable) {
if (slot.empty) {
ItemStack air = new ItemStack(Material.AIR);
inventory.setItem(slot.slot, air);
} else {
if (slot.togglePermission) {
if (player.hasPermission(slot.togglePermissionPerm)) {
toggleOn(slot, player, inventory);
} else {
toggleOff(slot, player, inventory);
}
} else if (slot.toggleUseItem) {
if (Events.useItemHashMap.get(player)) {
toggleOn(slot, player, inventory);
} else {
toggleOff(slot, player, inventory);
}
for (Slot slot : gui.slots) {
Function function = Main.functionHashMap.get(slot.function);
if (slot.permission || !player.hasPermission(slot.permissionToSee)) continue;
if (slot.enable) {
if (function.empty) {
ItemStack air = new ItemStack(Material.AIR);
inventory.setItem(slot.slot, air);
} else {
if (function.togglePermission) {
if (player.hasPermission(function.togglePermissionPerm)) {
toggleOn(function, slot.slot, player, inventory);
} else {
if (slot.playerHead_Enable) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, slot.name));
send.error(plugin, "Playerheads are only available from version 1.13!");
send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, slot.name));
toggleOff(function, slot.slot, player, inventory);
}
} else if (function.toggleUseItem) {
if (Events.useItemHashMap.get(player)) {
toggleOn(function, slot.slot, player, inventory);
} else {
toggleOff(function, slot.slot, player, inventory);
}
} else {
if (function.playerHead_Enable) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" +
Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
send.error(plugin, "Playerheads are only available from version 1.13!");
send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" +
(slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
} else {
if (function.base64_Enable) {
GuiBuilder.base64(function, slot.slot, player, inventory);
} else {
if (slot.base64_Enable) {
GuiBuilder.base64(slot, player, inventory);
if (function.playerWhoHasOpenedTheGUI) {
GuiBuilder.playerHead(function, slot.slot, player, inventory, player.getName());
} else {
if (slot.playerWhoHasOpenedTheGUI) {
GuiBuilder.playerHead(slot, player, inventory, player.getName());
} else {
GuiBuilder.playerHead(slot, player, inventory,slot.playerName);
}
GuiBuilder.playerHead(function, slot.slot, player, inventory, function.playerName);
}
}
} else {
GuiBuilder.item(slot, player, inventory);
}
} else {
GuiBuilder.item(function, slot.slot, player, inventory);
}
}
}
}
}
player.openInventory(inventory);
@ -126,15 +126,15 @@ public class OpenGUI {
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name)));
}
private static void toggleOn(Slot slot, Player player, Inventory inventory) {
private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) {
if (SelectConfig.toggleItemOnOrYesBase64) {
GuiBuilder.base64(SelectConfig.toggleItemOnOrYesBase64Value, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.toggleItemOnOrYesMaterial, slot, player, inventory);
GuiBuilder.base64(SelectConfig.toggleItemOnOrYesBase64Value, function, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.toggleItemOnOrYesMaterial, function, slot, player, inventory);
}
private static void toggleOff(Slot slot, Player player, Inventory inventory) {
private static void toggleOff(Function function, Integer slot, Player player, Inventory inventory) {
if (SelectConfig.toggleItemOffOrNoBase64) {
GuiBuilder.base64(SelectConfig.toggleItemOffOrNoBase64Value, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.toggleItemOffOrNoMaterial, slot, player, inventory);
GuiBuilder.base64(SelectConfig.toggleItemOffOrNoBase64Value, function, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.toggleItemOffOrNoMaterial, function, slot, player, inventory);
}
}

View File

@ -0,0 +1,162 @@
package de.jatitv.commandguiv2.Spigot.objects;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Obj_Select {
public static void onSelect() {
onSelectGui();
onSelectFunction();
}
public static void onSelectGui() {
Main.guiHashMap.clear();
Main.allAliases.clear();
File f = new File(Main.getPath() + "/GUIs/");
File[] fileArray = f.listFiles();
for (File config_gui : fileArray) {
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (sub.equals(".yml")) {
Main.allAliases.add(config_gui.getName().replace(".yml", ""));
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui);
String guiFileName = config_gui.getName().replace(".yml", "");
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
yamlConfiguration_gui.set("GUI.Lines", 6);
}
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
yamlConfiguration_gui.set("GUI.Lines", 1);
}
String guiName = yamlConfiguration_gui.getString("GUI.Name");
Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
String guiFillItemItem;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor");
} else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item");
Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
ArrayList<Slot> slots = new ArrayList<>();
for (String key : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + key + ".Slot") - 1;
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + key + ".Enable");
String function = yamlConfiguration_gui.getString("Slots." + key + ".Function");
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required");
String permSee = yamlConfiguration_gui.getString("Slots." + key + ".Permission.See");
String permUse = yamlConfiguration_gui.getString("Slots." + key + ".Permission.Use");
Slot slot = new Slot(slotNumber, enable, function, permRequired,
Objects.requireNonNull(permSee).replace("[guiname]", guiFileName).replace("[slot]", String.valueOf(slotNumber))
.replace("[slotname]", key), permUse);
slots.add(slot);
}
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
config_gui.getName().replace(".yml", ""), commandAliasEnable, commandPermission, slots);
Main.guiHashMap.put(guiFileName, gui);
CmdExecuter_GUITab.arg1.put(config_gui.getName()
.replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", ""));
try {
yamlConfiguration_gui.save(config_gui);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void onSelectFunction() {
Main.functionHashMap.clear();
File f = new File(Main.getPath() + "/Functions/");
File[] fileArray = f.listFiles();
for (File config : fileArray) {
String sub = config.getName().substring(config.getName().length() - 4);
if (sub.equals(".yml")) {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
Boolean empty = yamlConfiguration.getBoolean("Slots.Function.Item.Empty");
Integer itemAmount = yamlConfiguration.getInt("Slots.Function.Item.Amount");
Boolean playerHead_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Enable");
Boolean base64_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Base64.Enable");
String base64Value = yamlConfiguration.getString("Slots.Function.Item.PlayerHead.Base64.Base64Value");
Boolean playerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
String playerName = yamlConfiguration.getString("Slots.Function.Item.PlayerHead.PlayerName");
String item = yamlConfiguration.getString("Slots.Function.Item.Material");
String name = yamlConfiguration.getString("Slots.Function.Item.Name");
List<String> lore = yamlConfiguration.getStringList("Slots.Function.Item.Lore");
Boolean customSound_Enable = yamlConfiguration.getBoolean("Slots.Function.CustomSound.Enable");
Boolean customSound_NoSound = yamlConfiguration.getBoolean("Slots.Function.CustomSound.NoSound");
String customSound_Sound = yamlConfiguration.getString("Slots.Function.CustomSound.Sound");
Boolean cost_Enable = yamlConfiguration.getBoolean("Slots.Function.Cost.Enable");
Double price = yamlConfiguration.getDouble("Slots.Function.Cost.Price");
Boolean command_Enable = yamlConfiguration.getBoolean("Slots.Function.Command.Enable");
Boolean command_BungeeCommand = yamlConfiguration.getBoolean("Slots.Function.Command.BungeeCommand");
Boolean commandAsConsole = yamlConfiguration.getBoolean("Slots.Function.Command.CommandAsConsole");
List<String> command = yamlConfiguration.getStringList("Slots.Function.Command.Command");
Boolean serverChange = yamlConfiguration.getBoolean("Slots.Function.ServerChange.Enable");
String serverChangeServer = yamlConfiguration.getString("Slots.Function.ServerChange.Server");
Boolean openGUI_Enable = yamlConfiguration.getBoolean("Slots.Function.OpenGUI.Enable");
String openGUI = yamlConfiguration.getString("Slots.Function.OpenGUI.GUI");
Boolean togglePermission = yamlConfiguration.getBoolean("Slots.Function.Toggle.Permission.Enable");
String togglePermissionPerm = yamlConfiguration.getString("Slots.Function.Toggle.Permission.Permission");
Boolean toggleUseItem = yamlConfiguration.getBoolean("Slots.Function.Toggle.UseItem.Enable");
Boolean message_Enable = yamlConfiguration.getBoolean("Slots.Function.Message.Enable");
List<String> message = yamlConfiguration.getStringList("Slots.Function.Message.Message");
Boolean setConfigEnable = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Enable");
String configFilePath = yamlConfiguration.getString("Slots.Function.SetConfig.File.Path");
String configOptionPath = yamlConfiguration.getString("Slots.Function.SetConfig.Option.Path");
String configOptionPremat = yamlConfiguration.getString("Slots.Function.SetConfig.Option.Premat");
// Boolean ConfigChatInput = ;
String configStringValueLeft = yamlConfiguration.getString("Slots.Function.SetConfig.Value.LeftClick.String");
Boolean configBooleanValueLeft = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Value.LeftClick.Boolean");
Integer configIntegerValueLeft = yamlConfiguration.getInt("Slots.Function.SetConfig.Value.LeftClick.Integer");
Double configDoubleValueLeft = yamlConfiguration.getDouble("Slots.Function.SetConfig.Value.LeftClick.Double");
List<String> configListValueLeft = yamlConfiguration.getStringList("Slots.Function.SetConfig.Value.LeftClick.List");
String configStringValueRight = yamlConfiguration.getString("Slots.Function.SetConfig.Value.RightClick.String");
Boolean configBooleanValueRight = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Value.RightClick.Boolean");
Integer configIntegerValueRight = yamlConfiguration.getInt("Slots.Function.SetConfig.Value.RightClick.Integer");
Double configDoubleValueRight = yamlConfiguration.getDouble("Slots.Function.SetConfig.Value.RightClick.Double");
List<String> configListValueRight = yamlConfiguration.getStringList("Slots.Function.SetConfig.RightClick.Value.List");
Boolean pluginReloadEnable = yamlConfiguration.getBoolean("Slots.Function.SetConfig.PluginReload.Enable");
String pluginReloadCommand = yamlConfiguration.getString("Slots.Function.SetConfig.PluginReload.Command");
Function function = new Function(empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore,
customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, price, command_Enable, command_BungeeCommand, commandAsConsole, command,
serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, message,
setConfigEnable, configFilePath, configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft,
configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight,
configListValueRight, pluginReloadEnable, pluginReloadCommand);
Main.functionHashMap.put(config.getName().replace(".yml", ""), function);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -1,12 +1,9 @@
package de.jatitv.commandguiv2.Spigot.Objekte;
package de.jatitv.commandguiv2.Spigot.objects.functions;
import java.util.List;
public class Slot {
public class Function {
public Integer slot;
public Boolean enable;
// public Boolean ItemsRemovable;
public Boolean empty;
public Integer itemAmount;
public Boolean playerHead_Enable;
@ -35,12 +32,11 @@ public class Slot {
public Boolean toggleUseItem;
public Boolean message_Enable;
public List<String> message;
public Boolean perm;
public Boolean setConfigEnable;
public String configFilePath;
public String configOptionPath;
public String configOptionPremat;
// public Boolean ConfigChatInput;
// public Boolean ConfigChatInput;
public String configStringValueLeft;
public Boolean configBooleanValueLeft;
@ -58,60 +54,53 @@ public class Slot {
public Boolean pluginReloadEnable;
public String pluginReloadCommand;
public Slot(Integer slot,
Boolean enable,
// Boolean ItemsRemovable,
Boolean empty,
Integer itemAmount,
Boolean playerHead_Enable,
Boolean base64Value_Enable,
String base64Value,
Boolean playerWhoHasOpenedTheGUI,
String playerName,
String item,
String name,
List<String> lore,
Boolean customSound_Enable,
Boolean customSound_NoSound,
String customSound_Sound,
Boolean cost_Enable,
Double price,
Boolean command_Enable,
Boolean command_BungeeCommand,
Boolean commandAsConsole,
List<String> command,
Boolean serverChange,
String serverChangeServer,
Boolean openGUI_Enable,
String openGUI,
Boolean togglePermission,
String togglePermissionPerm,
Boolean toggleUseItem,
Boolean message_Enable,
List<String> message,
Boolean perm,
Boolean setConfigEnable,
String configFilePath,
String configOptionPath,
String configOptionPremat,
public Function(Boolean empty,
Integer itemAmount,
Boolean playerHead_Enable,
Boolean base64Value_Enable,
String base64Value,
Boolean playerWhoHasOpenedTheGUI,
String playerName,
String item,
String name,
List<String> lore,
Boolean customSound_Enable,
Boolean customSound_NoSound,
String customSound_Sound,
Boolean cost_Enable,
Double price,
Boolean command_Enable,
Boolean command_BungeeCommand,
Boolean commandAsConsole,
List<String> command,
Boolean serverChange,
String serverChangeServer,
Boolean openGUI_Enable,
String openGUI,
Boolean togglePermission,
String togglePermissionPerm,
Boolean toggleUseItem,
Boolean message_Enable,
List<String> message,
Boolean setConfigEnable,
String configFilePath,
String configOptionPath,
String configOptionPremat,
String configStringValueLeft,
Boolean configBooleanValueLeft,
Integer configIntegerValueLeft,
Double configDoubleValueLeft,
List<String> configListValueLeft,
String configStringValueLeft,
Boolean configBooleanValueLeft,
Integer configIntegerValueLeft,
Double configDoubleValueLeft,
List<String> configListValueLeft,
String configStringValueRight,
Boolean configBooleanValueRight,
Integer configIntegerValueRight,
Double configDoubleValueRight,
List<String> configListValueRight,
String configStringValueRight,
Boolean configBooleanValueRight,
Integer configIntegerValueRight,
Double configDoubleValueRight,
List<String> configListValueRight,
Boolean pluginReloadEnable,
String pluginReloadCommand) {
this.slot = slot;
this.enable = enable;
// this.ItemsRemovable = ItemsRemovable;
Boolean pluginReloadEnable,
String pluginReloadCommand) {
this.empty = empty;
this.itemAmount = itemAmount;
this.playerHead_Enable = playerHead_Enable;
@ -140,12 +129,11 @@ public class Slot {
this.toggleUseItem = toggleUseItem;
this.message_Enable = message_Enable;
this.message = message;
this.perm = perm;
this.setConfigEnable = setConfigEnable;
this.configFilePath = configFilePath;
this.configOptionPath = configOptionPath;
this.configOptionPremat = configOptionPremat;
// this.ConfigChatInput = ConfigChatInput;
// this.ConfigChatInput = ConfigChatInput;
this.configStringValueLeft = configStringValueLeft;
this.configBooleanValueLeft = configBooleanValueLeft;
@ -162,5 +150,8 @@ public class Slot {
this.pluginReloadEnable = pluginReloadEnable;
this.pluginReloadCommand = pluginReloadCommand;
}
}

View File

@ -1,8 +1,10 @@
package de.jatitv.commandguiv2.Spigot.Objekte;
package de.jatitv.commandguiv2.Spigot.objects.guis;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import java.util.ArrayList;
public class Object {
public class Gui {
public Boolean GUI_Enable;
public Integer GUI_Lines;
public String GUI_Name;
@ -13,10 +15,10 @@ public class Object {
public String Command_Command;
public Boolean Command_Alias_Enable;
public Boolean Command_Permission_Enable;
public ArrayList<Slot> GUI_Slots;
public ArrayList<Slot> slots;
public Object(Boolean GUI_Enable, Integer GUI_Lines, String GUI_Name, Boolean GUI_FillItem_Enable, String GUI_FillItem_Item,
String Command_Command, Boolean Command_Alias_Enable, Boolean Command_Permission_Enable, ArrayList<Slot> GUI_Slots){
public Gui(Boolean GUI_Enable, Integer GUI_Lines, String GUI_Name, Boolean GUI_FillItem_Enable, String GUI_FillItem_Item,
String Command_Command, Boolean Command_Alias_Enable, Boolean Command_Permission_Enable, ArrayList<Slot> slots){
this.GUI_Enable = GUI_Enable;
this.GUI_Lines = GUI_Lines;
this.GUI_Name = GUI_Name;
@ -25,6 +27,6 @@ public class Object {
this.Command_Command = Command_Command;
this.Command_Alias_Enable = Command_Alias_Enable;
this.Command_Permission_Enable = Command_Permission_Enable;
this.GUI_Slots = GUI_Slots;
this.slots = slots;
}
}

View File

@ -0,0 +1,28 @@
package de.jatitv.commandguiv2.Spigot.objects.slots;
public class Slot {
public Integer slot;
public Boolean enable;
public String function;
public Boolean permission;
public String permissionToSee;
public String permissionToUse;
public Slot(Integer slot,
Boolean enable,
String function,
Boolean permission,
String permissionToSee,
String permissionToUse
) {
this.slot = slot;
this.enable = enable;
this.function = function;
this.permission = permission;
this.permissionToSee = permissionToSee;
this.permissionToUse = permissionToUse;
}
}

View File

@ -6,14 +6,15 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Spigot.Listener.PluginEvent;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Obj_Select;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
@ -44,7 +45,12 @@ public class Load {
if (!new File(Main.getPath(), "config.yml").exists()) {
try {
DefaultGUICreate.configCreate();
CreateGUI.configCreate();
} catch (Exception e) {
e.printStackTrace();
}
try {
CreateFunctions.create();
} catch (Exception e) {
e.printStackTrace();
}
@ -61,17 +67,17 @@ public class Load {
}
if (SelectConfig.Bungee) {
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin,"cgui:bungee")){
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) {
send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin,"cgui:bungee");
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "cgui:bungee");
}
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin,"cgui:onlinepl")){
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "cgui:onlinepl")) {
send.debug(plugin, "registerIncomingPluginChannel §ecgui:onlinepl");
Bukkit.getMessenger().registerIncomingPluginChannel(plugin,"cgui:onlinepl", new Bungee_Sender_Reciver());
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "cgui:onlinepl", new Bungee_Sender_Reciver());
}
}
if (PluginCheck.papi()){
if (PluginCheck.papi()) {
new Placeholder().register();
}

View File

@ -1,20 +1,24 @@
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission;
public class RegisterPermissions {
public static void onPermRegister() {
for (Object gui : Main.guiHashMap.values()) {
for (Gui gui : Main.guiHashMap.values()) {
if (Bukkit.getPluginManager().getPermission("commandgui.command." + gui.Command_Command) == null) {
Bukkit.getPluginManager().addPermission(new Permission("commandgui.command." + gui.Command_Command));
}
for (Slot slot : gui.GUI_Slots) {
if (Bukkit.getPluginManager().getPermission("commandgui." + gui.Command_Command + ".slot." + (slot.slot + 1)) == null) {
Bukkit.getPluginManager().addPermission(new Permission("commandgui." + gui.Command_Command + ".slot." + (slot.slot + 1)));
for (Slot slot : gui.slots) {
if (Bukkit.getPluginManager().getPermission(slot.permissionToUse) == null) {
Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToUse));
}
if (Bukkit.getPluginManager().getPermission(slot.permissionToSee) == null) {
Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToSee));
}
}
}

View File

@ -11,7 +11,7 @@ import java.io.IOException;
public class YML {
private static Plugin plugin = Main.plugin;
private static final Plugin plugin = Main.plugin;
public static File storage = new File(Main.getPath(), "Storage/gui-item.yml");
public static YamlConfiguration yamlConfigurationStorage = YamlConfiguration.loadConfiguration(storage);

View File

@ -1,6 +1,7 @@
package de.jatitv.commandguiv2;
public class Util {
private static Integer configVersion = 5;
private static double requiredT2CodeLibVersion = 10.3;
private static String Prefix = "§8[§4C§9GUI§8]";
private static Integer SpigotID = 90671;
@ -31,4 +32,8 @@ public class Util {
public static String getDiscord() {
return Discord;
}
public static Integer getConfigVersion() {
return configVersion;
}
}

View File

@ -5,7 +5,7 @@ import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Help;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
@ -81,7 +81,7 @@ public class CGuiAPI {
public static void createDefaultGUI(CommandSender sender) {
if (sender.hasPermission("commandgui.admin")) {
DefaultGUICreate.configCreate();
CreateGUI.configCreate();
sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));