1 Commits

Author SHA1 Message Date
d96205887c Config poll 2022-04-16 15:46:26 +02:00
50 changed files with 1129 additions and 1350 deletions

View File

@@ -6,9 +6,10 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.7.0_Snapshot-1</version>
<version>2.6.2_Snapshot-2</version>
<packaging>jar</packaging>
<name>CommandGUI</name>
<properties>
@@ -65,10 +66,6 @@
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
@@ -93,16 +90,91 @@
<artifactId>LuckyBox-API</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_18.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.18r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_18.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.18r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_17.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.17r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_16.r3</groupId>
<artifactId>spigot</artifactId>
<version>1.16r3</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_16.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.16r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_16.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.16r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_15.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.15r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_14.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.14r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_13.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.13r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_13.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.13r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_12.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.12r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_11.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.11r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_10.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.10r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_9.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.9r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_9.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.9r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_8.r3</groupId>
<artifactId>spigot</artifactId>
<version>1.8r3</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_8.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.8r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_8.r1</groupId>
<artifactId>spigot</artifactId>
@@ -111,23 +183,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.22</version>
<version>3.4.5</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,34 @@
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,12 +1,9 @@
package de.jatitv.commandguiv2.Spigot.Listener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
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.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.system.Bungee_Sender_Reciver;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.Main;
@@ -43,60 +40,56 @@ public class GUI_Listener implements Listener {
JavaPlugin plugin = Main.plugin;
if (e.getInventory() == null) return;
if (e.getCurrentItem() == null) return;
for (Gui gui : Main.guiHashMap.values()) {
for (Object 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.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(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);
for (Slot slot : gui.GUI_Slots) {
if (e.getSlot() != slot.Slot) continue;
if (e.getCurrentItem().getType() == ItemVersion.getHead() || 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);
}
}
}
} else 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)));
}
}
}
}
}
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 execute(Slot slot, Player player, InventoryClickEvent e, Object gui) {
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 command(Function slot, Player player) {
private static void command(Slot slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
@@ -106,18 +99,18 @@ public class GUI_Listener implements Listener {
new BukkitRunnable() {
@Override
public void run() {
if (slot.command_BungeeCommand) {
if (slot.Command_BungeeCommand) {
if (SelectConfig.Bungee) {
for (String cmd : slot.command) {
Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.commandAsConsole);
for (String cmd : slot.Command) {
Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole);
}
} else {
send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
for (String cmd : slot.command) {
if (slot.commandAsConsole) {
for (String cmd : slot.Command) {
if (slot.CommandAsConsole) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName()));
} else player.chat("/" + cmd.replace("[player]", player.getName()));
}
@@ -126,82 +119,93 @@ public class GUI_Listener implements Listener {
}.runTaskLater(plugin, 2L);
}
private static void openGUI(Function slot, Player player) {
player.closeInventory();
new BukkitRunnable() {
@Override
public void run() {
OpenGUI.openGUI(player, slot.openGUI);
}
}.runTaskLater(plugin, 1L);
}
private static void message(Function slot, Player player) {
private static void openGUI(Slot slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
for (String msg : slot.message) {
new BukkitRunnable() {
@Override
public void run() {
OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI);
}
}.runTaskLater(plugin, 2L);
}
private static void message(Slot slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
for (String msg : slot.Message) {
if (Main.PaPi) {
if (slot.cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.price + " " + SelectConfig.Currency));
if (slot.Cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.Price + " " + SelectConfig.Currency));
} else player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix)));
} else {
if (slot.cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, msg, slot.price + " " + SelectConfig.Currency));
if (slot.Cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, msg, slot.Price + " " + SelectConfig.Currency));
} else player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix)));
}
}
}
private static void serverChange(Function slot, Player player) {
private static void serverChange(Slot slot, Player player) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
send.player(player, SelectMessages.onServerChange.replace("[server]", slot.serverChangeServer));
send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer));
new BukkitRunnable() {
@Override
public void run() {
ServerChange.send(player, slot.serverChangeServer);
ServerChange.send(player, slot.ServerChangeServer);
}
}.runTaskLater(Main.plugin, 20L);
}
private static void setConfig(Function slot, Player player, InventoryClickEvent e) {
File config = new File(slot.configFilePath);
private static void setConfig(Slot slot, Player player, InventoryClickEvent e) {
File config = new File(slot.ConfigFilePath);
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
/*if (slot.ConfigChatInput){
ConfigChat.EditChat.put(player, slot.ConfigOptionPath);
player.sendMessage(DefaultValue.SettingsGUIchatSet.replace("[setting]", "Shop Name Chest small"));
player.sendMessage(DefaultValue.SettingsGUIchatCancel);
} else
{
*/
if (e.getClick() == ClickType.LEFT) {
if (slot.configOptionPremat.equals("String")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configStringValueLeft);
} else if (slot.configOptionPremat.equals("Boolean")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configBooleanValueLeft);
} else if (slot.configOptionPremat.equals("Integer")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configIntegerValueLeft);
} else if (slot.configOptionPremat.equals("Double")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configDoubleValueLeft);
} else if (slot.configOptionPremat.equals("List")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueLeft);
if (slot.ConfigOptionPremat.equals("String")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft);
} else if (slot.ConfigOptionPremat.equals("Boolean")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft);
} else if (slot.ConfigOptionPremat.equals("Integer")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft);
} else if (slot.ConfigOptionPremat.equals("Double")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft);
} else if (slot.ConfigOptionPremat.equals("List")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft);
} else {
player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo
}
}
if (e.getClick() == ClickType.RIGHT) {
if (slot.configOptionPremat.equals("String")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configStringValueRight);
} else if (slot.configOptionPremat.equals("Boolean")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configBooleanValueRight);
} else if (slot.configOptionPremat.equals("Integer")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configIntegerValueRight);
} else if (slot.configOptionPremat.equals("Double")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configDoubleValueRight);
} else if (slot.configOptionPremat.equals("List")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueRight);
if (slot.ConfigOptionPremat.equals("String")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight);
} else if (slot.ConfigOptionPremat.equals("Boolean")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight);
} else if (slot.ConfigOptionPremat.equals("Integer")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight);
} else if (slot.ConfigOptionPremat.equals("Double")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight);
} else if (slot.ConfigOptionPremat.equals("List")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight);
} else {
player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo
}
@@ -211,8 +215,8 @@ public class GUI_Listener implements Listener {
} catch (IOException tac) {
tac.printStackTrace();
}
if (slot.pluginReloadEnable) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.pluginReloadCommand);
if (slot.PluginReloadEnable) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand);
}
new BukkitRunnable() {
@Override
@@ -222,31 +226,20 @@ public class GUI_Listener implements Listener {
}.runTaskLater(plugin, 1L);
}
private static void sound(Function function, Slot slot, Player player, Gui gui) {
if (function.customSound_Enable) {
if (!function.customSound_NoSound) {
private static void sound(Slot slot, Player player, Object gui) {
if (slot.CustomSound_Enable) {
if (!slot.CustomSound_NoSound) {
try {
player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
player.playSound(player.getLocation(), Sound.valueOf(slot.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" + function.customSound_Sound));
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound));
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
}
}
} else player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
}
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
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm));
}
private static void toggleUseItem(Player player) {
if (Events.useItemHashMap.get(player)) {
Commands.itemOff(player);
} else Commands.itemOn(player);
}
}

View File

@@ -1,6 +1,5 @@
package de.jatitv.commandguiv2.Spigot.Listener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.Give_UseItem;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
@@ -18,13 +17,12 @@ public class ItemChange {
if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot;
} else {
if (Events.useItemSlotHashMap.get(player) == null) {
if (Select_Database.selectSlot(player) == null) {
slot = SelectConfig.UseItem_InventorySlot;
} else {
slot = Events.useItemSlotHashMap.get(player);
slot = Select_Database.selectSlot(player);
}
}
if (!SelectConfig.UseItem_Enable) {
return;
}
@@ -53,7 +51,7 @@ public class ItemChange {
}
}
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
if (!player.hasPlayedBefore()) {
new BukkitRunnable() {
@Override
@@ -80,7 +78,7 @@ public class ItemChange {
@Override
public void run() {
removeItem(player);
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
send.debug(Main.plugin,"Give: " +player.getName());
Give_UseItem.onGive(player);
@@ -102,7 +100,6 @@ public class ItemChange {
}
}
}.runTaskLater(Main.plugin, 1L * 1);
}
private static void setCursor(Player player, int slot) {
@@ -154,6 +151,5 @@ public class ItemChange {
}
}
}
}
}

View File

@@ -23,10 +23,9 @@ public class PluginEvent implements Listener {
public void onJoinEvent(PlayerLoginEvent event) {
Player player = event.getPlayer();
Select_Database.nameCheck(player);
UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
UpdateAPI.join(Main.plugin, prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
}
@EventHandler
public void onClearServer(ServerCommandEvent event) {
if (SelectConfig.UseItem_KeepAtCommandClear) {
@@ -36,11 +35,11 @@ public class PluginEvent implements Listener {
public void run() {
try {
Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", ""));
if (player == null){
if (player == null) {
return;
}
clearGive(player);
} catch (Exception ex){
} catch (Exception ex) {
ex.printStackTrace();
return;
}
@@ -50,7 +49,6 @@ public class PluginEvent implements Listener {
}
}
@EventHandler
public void onClearPlayer(PlayerCommandPreprocessEvent event) {
if (SelectConfig.UseItem_KeepAtCommandClear) {

View File

@@ -6,12 +6,11 @@ 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;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -28,21 +27,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
public class Events implements Listener {
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>();
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>();
@EventHandler
public void onJoin(PlayerJoinEvent e) {
if (Select_Database.selectItemStatus(e.getPlayer())){
useItemHashMap.put(e.getPlayer(), true);
} else useItemHashMap.put(e.getPlayer(), false);
useItemSlotHashMap.put(e.getPlayer(),Select_Database.selectSlot(e.getPlayer()));
if (CGuiAPI.JoinDisable) {
send.debug(Main.plugin,"JoinDisable");
return;
@@ -58,11 +48,6 @@ public class Events implements Listener {
}
}
@EventHandler
public void onJoin(PlayerQuitEvent e) {
useItemHashMap.remove(e.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onDeathDrop(PlayerDeathEvent e) {
Player player = e.getEntity().getPlayer();
@@ -95,25 +80,6 @@ public class Events implements Listener {
Player player = e.getPlayer();
if (SelectConfig.UseItem_Enable) {
ItemChange.itemChange(player, false);
//if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
// if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
// if (!player.hasPlayedBefore()) {
// new BukkitRunnable() {
// @Override
// public void run() {
// Give_UseItem.onGive(player);
// }
// }.runTaskLater(Main.plugin, 20L * 1);
// }
// } else {
// new BukkitRunnable() {
// @Override
// public void run() {
// Give_UseItem.onGive(player);
// }
// }.runTaskLater(Main.plugin, 20L * 1);
// }
//}
}
}
@@ -145,7 +111,6 @@ public class Events implements Listener {
}.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
@@ -201,7 +166,7 @@ public class Events implements Listener {
}
}
if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI);
OpenGUI.openGUI(p, Main.guiHashMap.get(SelectConfig.UseItem_OpenGUI), SelectConfig.UseItem_OpenGUI);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
@@ -221,7 +186,6 @@ public class Events implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryDragEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
@@ -294,7 +258,7 @@ public class Events implements Listener {
}
private static boolean legacy() {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15|| NMSVersion.v1_16_R1) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15) {
return true;
} else return false;
}

View File

@@ -1,9 +1,9 @@
package de.jatitv.commandguiv2.Spigot;
//s<ds
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.Load;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
@@ -43,11 +43,9 @@ public final class Main extends JavaPlugin {
public static Boolean LuckyBox = false;
public static Boolean PlugManGUI = false;
public static HashMap<String, Gui> guiHashMap = new HashMap<>();
public static HashMap<String, Object> 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());
@@ -71,7 +69,8 @@ public final class Main extends JavaPlugin {
if (PluginCheck.plotSquaredGUI()) {
PlotSquaredGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
}if (PluginCheck.luckyBox()) {
}
if (PluginCheck.luckyBox()) {
LuckyBox = true;
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
}

View File

@@ -0,0 +1,111 @@
package de.jatitv.commandguiv2.Spigot.Objekte;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
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.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.getList("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 + ".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_GUI.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

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

View File

@@ -0,0 +1,158 @@
package de.jatitv.commandguiv2.Spigot.Objekte;
import java.util.List;
public class Slot {
public Integer Slot;
public Boolean Enable;
// public Boolean ItemsRemovable;
public Boolean Empty;
public Integer ItemAmount;
public Boolean PlayerHead_Enable;
public Boolean Base64_Enable;
public String Base64Value;
public Boolean PlayerWhoHasOpenedTheGUI;
public String PlayerName;
public String Item;
public String Name;
public List Lore;
public Boolean CustomSound_Enable;
public Boolean CustomSound_NoSound;
public String CustomSound_Sound;
public Boolean Cost_Enable;
public Double Price;
public Boolean Command_Enable;
public Boolean Command_BungeeCommand;
public Boolean CommandAsConsole;
public Boolean ServerChange;
public String ServerChangeServer;
public List<String> Command;
public Boolean OpenGUI_Enable;
public String OpenGUI;
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 String ConfigStringValueLeft;
public Boolean ConfigBooleanValueLeft;
public Integer ConfigIntegerValueLeft;
public Double ConfigDoubleValueLeft;
public List<String> ConfigListValueLeft;
public String ConfigStringValueRight;
public Boolean ConfigBooleanValueRight;
public Integer ConfigIntegerValueRight;
public Double ConfigDoubleValueRight;
public List<String> ConfigListValueRight;
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 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 Message_Enable,
List<String> Message,
Boolean Perm,
Boolean SetConfigEnable,
String ConfigFilePath,
String ConfigOptionPath,
String ConfigOptionPremat,
// Boolean ConfigChatInput,
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) {
this.Slot = Slot;
this.Enable = Enable;
// this.ItemsRemovable = ItemsRemovable;
this.Empty = Empty;
this.ItemAmount = ItemAmount;
this.PlayerHead_Enable = PlayerHead_Enable;
this.Base64_Enable = Base64Value_Enable;
this.Base64Value = Base64Value;
this.PlayerWhoHasOpenedTheGUI = PlayerWhoHasOpenedTheGUI;
this.PlayerName = PlayerName;
this.Item = Item;
this.Name = Name;
this.Lore = Lore;
this.CustomSound_Enable = CustomSound_Enable;
this.CustomSound_NoSound = CustomSound_NoSound;
this.CustomSound_Sound = CustomSound_Sound;
this.Cost_Enable = Cost_Enable;
this.Price = Price;
this.Command_Enable = Command_Enable;
this.Command_BungeeCommand = Command_BungeeCommand;
this.CommandAsConsole = CommandAsConsole;
this.Command = Command;
this.ServerChange = ServerChange;
this.ServerChangeServer = ServerChangeServer;
this.OpenGUI_Enable = OpenGUI_Enable;
this.OpenGUI = OpenGUI;
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.ConfigStringValueLeft = ConfigStringValueLeft;
this.ConfigBooleanValueLeft = ConfigBooleanValueLeft;
this.ConfigIntegerValueLeft = ConfigIntegerValueLeft;
this.ConfigDoubleValueLeft = ConfigDoubleValueLeft;
this.ConfigListValueLeft = ConfigListValueLeft;
this.ConfigStringValueRight = ConfigStringValueRight;
this.ConfigBooleanValueRight = ConfigBooleanValueRight;
this.ConfigIntegerValueRight = ConfigIntegerValueRight;
this.ConfigDoubleValueRight = ConfigDoubleValueRight;
this.ConfigListValueRight = ConfigListValueRight;
this.PluginReloadEnable = PluginReloadEnable;
this.PluginReloadCommand = PluginReloadCommand;
}
}

View File

@@ -0,0 +1,151 @@
package de.jatitv.commandguiv2.Spigot.cmdManagement;
import de.jatitv.commandguiv2.Spigot.system.Debug;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class CmdExecuter_Admin implements CommandExecutor, TabCompleter {
private static String prefix = Util.getPrefix();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
Help.sendHelp(sender, prefix);
} else {
switch (args[0].toLowerCase()) {
case "info":
if (sender.hasPermission("commandgui.command.info")) {
Commands.info(sender);
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.command.info"));
break;
case "reload":
case "rl":
if (sender.hasPermission("commandgui.admin")) {
Commands.reload(sender);
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
break;
case "createdefaultgui":
if (sender.hasPermission("commandgui.admin")) {
DefaultGUICreate.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"));
break;
case "debug":
if (sender.hasPermission("commandgui.admin")) {
Debug.onDebugFile(sender);
/*if (args.length == 2) {
if (args[1].equals("config")) {
Debug.debugmsg();
}
if (args[1].equals("2")) {
send.debug("2");
}
break;
} else Debug.debugmsg();
*/
} else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
break;
case "give":
if (args.length == 2) {
if (sender.hasPermission("commandgui.giveitem.other")) {
Player target = Bukkit.getPlayer(args[1]);
Commands.give(sender, target);
} else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui give")
.replace("[perm]", "commandgui.command.give"));
} else Help.sendHelp(sender, prefix);
break;
case "help":
default:
Help.sendHelp(sender, prefix);
break;
}
}
return false;
}
//TabCompleter
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("reload", "commandgui.admin");
put("rl", "commandgui.admin");
put("createdefaultgui", "commandgui.admin");
put("give", "commandgui.giveitem.other");
put("info", "commandgui.command.info");
}};
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>();
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
Boolean passend = true;
for (int i = 0; i < args[0].length(); i++) {
if (args[0].length() >= command.length()) {
passend = false;
} else {
if (args[0].charAt(i) != command.charAt(i)) {
passend = false;
}
}
}
if (hasPermission(p, arg1.get(command)) && passend) {
list.add(command);
}
}
}
if (args.length == 2 && args[0].equalsIgnoreCase("give")) {
if (sender.hasPermission("commandgui.giveitem.other")) {
Iterator var6 = Bukkit.getOnlinePlayers().iterator();
while (var6.hasNext()) {
Player player1 = (Player) var6.next();
list.add(player1.getName());
}
}
return list;
}
}
return list;
}
public static boolean hasPermission(Player player, String permission) {
if (player.isOp()) {
return true;
}
String[] Permissions = permission.split(";");
for (String perm : Permissions) {
if (player.hasPermission(perm)) {
return true;
}
}
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.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.commands.Tab;
@@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter {
public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
private static String prefix = Util.getPrefix();
@Override
@@ -56,7 +56,7 @@ public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter {
break;
case "createdefaultgui":
if (sender.hasPermission("commandgui.admin")) {
CreateGUI.configCreate();
DefaultGUICreate.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

@@ -55,8 +55,7 @@ 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

@@ -1,9 +1,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.objects.Obj_Select;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.Objekte.Obj_Select;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.Give_UseItem;
@@ -60,8 +59,8 @@ public class Commands {
send.console(Util.getPrefix() + " §6Plugin reload...");
send.console(Util.getPrefix() + "§8-------------------------------");
CmdExecuter_GUITab.arg1.clear();
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
CmdExecuter_GUI.arg1.clear();
CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
ConfigCreate.configCreate();
SelectConfig.onSelect();
Main.plugin.reloadConfig();
@@ -71,13 +70,11 @@ public class Commands {
Obj_Select.onSelect();
SelectMessages.onSelect(Util.getPrefix());
SelectConfig.sound(Util.getPrefix());
try {
AliasRegister.onRegister();
} catch (Exception e) {
e.printStackTrace();
}
if (SelectConfig.Bungee) {
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee");
@@ -123,10 +120,10 @@ public class Commands {
if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot;
} else {
if (Events.useItemSlotHashMap.get(player) == null) {
if (Select_Database.selectSlot(player) == null) {
slot = SelectConfig.UseItem_InventorySlot;
} else {
slot = Events.useItemSlotHashMap.get(player);
slot = Select_Database.selectSlot(player);
}
}
send.debug(Main.plugin, String.valueOf(slot));
@@ -206,7 +203,7 @@ public class Commands {
}
}
Select_Database.setSlot(player, setSlot);
if (Events.useItemHashMap.get(player)) {
if (Select_Database.selectItemStatus(player)) {
Give_UseItem.onGive(player);
}
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
@@ -215,10 +212,10 @@ public class Commands {
public static void gui(Player player) {
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
Object 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);
OpenGUI.openGUI(player, gui, SelectConfig.DefaultGUI);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
@@ -230,10 +227,10 @@ public class Commands {
public static void gui(Player player, String arg) {
if (Main.guiHashMap.containsKey(arg)) {
Gui gui = Main.guiHashMap.get(arg);
Object 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);
OpenGUI.openGUI(player, gui, arg);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}

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.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
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")) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
Object 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

@@ -1,14 +1,15 @@
package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap;
import org.bukkit.plugin.Plugin;
import org.eclipse.sisu.space.ClassFinder;
import java.io.File;
import java.lang.reflect.Field;
public class AliasRegister {
@@ -24,17 +25,97 @@ public class AliasRegister {
for (String alias : Main.allAliases) {
if (Main.guiHashMap.get(alias) != null) {
if (Main.guiHashMap.get(alias).Command_Alias_Enable) {
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
commandMap.register(alias, new RegisterCommand(alias));
} catch(Exception e) {
e.printStackTrace();
String version;
if (NMSVersion.v1_8_R1) {
send.debug(plugin, "Alias register 1.8_R1");
org.bukkit.craftbukkit.v1_8_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_8_R2) {
send.debug(plugin, "Alias register 1.8_R2");
org.bukkit.craftbukkit.v1_8_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R2.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_8_R3) {
send.debug(plugin, "Alias register 1.8_R3");
org.bukkit.craftbukkit.v1_8_R3.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R3.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_9_R1) {
send.debug(plugin, "Alias register 1.9_R1");
org.bukkit.craftbukkit.v1_9_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_9_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_9_R2) {
send.debug(plugin, "Alias register 1.9_R2");
org.bukkit.craftbukkit.v1_9_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_9_R2.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_10_R1) {
send.debug(plugin, "Alias register 1.10_R1");
org.bukkit.craftbukkit.v1_10_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_10_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_11_R1) {
send.debug(plugin, "Alias register 1.11_R1");
org.bukkit.craftbukkit.v1_11_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_11_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_12_R1) {
send.debug(plugin, "Alias register 1.12_R1");
org.bukkit.craftbukkit.v1_12_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_12_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_13_R1) {
send.debug(plugin, "Alias register 1.13_R1");
org.bukkit.craftbukkit.v1_13_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_13_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_13_R2) {
send.debug(plugin, "Alias register 1.13_R2");
org.bukkit.craftbukkit.v1_13_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_13_R2.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_14_R1) {
send.debug(plugin, "Alias register 1.14_R1");
org.bukkit.craftbukkit.v1_14_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_14_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_15_R1) {
send.debug(plugin, "Alias register 1.15_R1");
org.bukkit.craftbukkit.v1_15_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_15_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_16_R1) {
send.debug(plugin, "Alias register 1.16_R1");
org.bukkit.craftbukkit.v1_16_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_16_R2) {
send.debug(plugin, "Alias register 1.16_R2");
org.bukkit.craftbukkit.v1_16_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R2.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_16_R3) {
send.debug(plugin, "Alias register 1.16_R3");
org.bukkit.craftbukkit.v1_16_R3.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R3.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_17_R1) {
send.debug(plugin, "Alias register 1.17_R1");
org.bukkit.craftbukkit.v1_17_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_17_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_18_R1) {
send.debug(plugin, "Alias register 1.18_R1");
org.bukkit.craftbukkit.v1_18_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
if (NMSVersion.v1_18_R2) {
send.debug(plugin, "Alias register 1.18_R2");
org.bukkit.craftbukkit.v1_18_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R2.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
//Register.register(alias, plugin);
}
}
}

View File

@@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
@@ -23,10 +23,10 @@ public class RegisterCommand extends Command {
if (sender instanceof Player) {
Player player = (Player) sender;
Gui gui = Main.guiHashMap.get(alias);
Object 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);
OpenGUI.openGUI(player, gui, alias);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}

View File

@@ -0,0 +1,191 @@
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 {
private static Boolean GUI_Enable = true;
private static Integer GUI_Lines = 1;
private static String GUI_Name = "&5default &9GUI";
private static Boolean GUI_FillItem_Enable = true;
private static Integer GUI_FillItem_Item_1_8 = 15;
private static String GUI_FillItem_Item = "BLACK_STAINED_GLASS_PANE";
private static Boolean Command_Alias = true;
private static Boolean Command_Permission = true;
private static Integer slot = 5;
private static Boolean enable = true;
private static Boolean ItemEmty = false;
private static Integer ItemAmout = 1;
private static Boolean Playerhead_enable = true;
private static Boolean base64_Enable = true;
private static String base64value = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19";
private static Boolean PlayerWhoHasOpenedTheGUI = false;
private static String PlayerName = "";
private static String Item = "";
private static String Itemname = "&3Support Discord";
private static List ItemLore = 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");
private static Boolean CustomSound = false;
private static Boolean CustomSound_NoSound = false;
private static String CustomSound_Sound = "";
private static Boolean Cost = false;
private static Double Cost_Price = 0.0;
private static Boolean Command = false;
private static Boolean BungeeCommand = false;
private static Boolean CommandAsConsole = false;
private static List Commands = Arrays.asList();
private static Boolean Server_Change = false;
private static String Server_Change_Server = "";
private static Boolean OpenGUI = false;
private static String OpenGUI_GUI = "";
private static Boolean Message = true;
private static List Messages = Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net");
private static Boolean Permission = false;
private static Boolean SetConfig_Enable = false;
private static String SetConfig_FilePath = "";
private static String SetConfig_OptionPath = "";
private static String SetConfig_OptionPremat = "String";
private static String SetConfig_ValueLeftString = "";
private static Boolean SetConfig_ValueLeftBoolean = false;
private static Integer SetConfig_ValueLeftInteger = 0;
private static Double SetConfig_ValueLeftDouble = 0.0;
private static List SetConfig_ValueLeftList = Arrays.asList();
private static String SetConfig_ValueRightString = "";
private static Boolean SetConfig_ValueRightBoolean = false;
private static Integer SetConfig_ValueRightInteger = 0;
private static Double SetConfig_ValueRightDouble = 0.0;
private static List SetConfig_ValueRightList = Arrays.asList();
private static Boolean SetConfig_PluginReloadEnable = false;
private static String SetConfig_PluginReloadCommand = "";
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", GUI_Enable, yamlConfiguration);
set("GUI.Lines", GUI_Lines, yamlConfiguration);
set("GUI.Name", GUI_Name, yamlConfiguration);
set("GUI.FillItem.Enable", GUI_FillItem_Enable, yamlConfiguration);
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("GUI.FillItem.GlassPaneCollor", GUI_FillItem_Item_1_8, yamlConfiguration);
} else set("GUI.FillItem.Item", GUI_FillItem_Item, yamlConfiguration);
set("Command.Alias", Command_Alias, yamlConfiguration);
set("Command.Permission.Required", Command_Permission, yamlConfiguration);
set("Slots.Example.Slot", slot, yamlConfiguration);
set("Slots.Example.Enable", enable, yamlConfiguration);
set("Slots.Example.Item.Empty", ItemEmty, yamlConfiguration);
set("Slots.Example.Item.Amount", ItemAmout, yamlConfiguration);
if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
set("Slots.Example.Item.PlayerHead.Enable", Playerhead_enable, yamlConfiguration);
set("Slots.Example.Item.PlayerHead.Base64.Enable", base64_Enable, yamlConfiguration);
set("Slots.Example.Item.PlayerHead.Base64.Base64Value", base64value, yamlConfiguration);
set("Slots.Example.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", PlayerWhoHasOpenedTheGUI, yamlConfiguration);
set("Slots.Example.Item.PlayerHead.PlayerName", PlayerName, yamlConfiguration);
}
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
set("Slots.Example.Item.Material", "TNT", yamlConfiguration);
} else set("Slots.Example.Item.Material", Item, yamlConfiguration);
set("Slots.Example.Item.Name", Itemname, yamlConfiguration);
set("Slots.Example.Item.Lore", ItemLore, yamlConfiguration);
set("Slots.Example.CustomSound.Enable", CustomSound, yamlConfiguration);
set("Slots.Example.CustomSound.NoSound", CustomSound_NoSound, yamlConfiguration);
set("Slots.Example.CustomSound.Sound", CustomSound_Sound, yamlConfiguration);
set("Slots.Example.Cost.Enable", Cost, yamlConfiguration);
set("Slots.Example.Cost.Price", Cost_Price, yamlConfiguration);
set("Slots.Example.Command.Enable", Command, yamlConfiguration);
set("Slots.Example.Command.BungeeCommand", BungeeCommand, yamlConfiguration);
set("Slots.Example.Command.CommandAsConsole", CommandAsConsole, yamlConfiguration);
set("Slots.Example.Command.Command", Commands, yamlConfiguration);
set("Slots.Example.ServerChange.Enable", Server_Change, yamlConfiguration);
set("Slots.Example.ServerChange.Server", Server_Change_Server, yamlConfiguration);
set("Slots.Example.OpenGUI.Enable", OpenGUI, yamlConfiguration);
set("Slots.Example.OpenGUI.GUI", OpenGUI_GUI, yamlConfiguration);
set("Slots.Example.Message.Enable", Message, yamlConfiguration);
set("Slots.Example.Message.Message", Messages, yamlConfiguration);
set("Slots.Example.Permission.Required", Permission, yamlConfiguration);
set("Slots.Example.SetConfig.Enable", SetConfig_Enable, yamlConfiguration);
set("Slots.Example.SetConfig.File.Path", SetConfig_FilePath, yamlConfiguration);
set("Slots.Example.SetConfig.Option.Path", SetConfig_OptionPath, yamlConfiguration);
set("Slots.Example.SetConfig.Option.Premat", SetConfig_OptionPremat, yamlConfiguration);
set("Slots.Example.SetConfig.Value.LeftClick.String", SetConfig_ValueLeftString, yamlConfiguration);
set("Slots.Example.SetConfig.Value.LeftClick.Boolean", SetConfig_ValueLeftBoolean, yamlConfiguration);
set("Slots.Example.SetConfig.Value.LeftClick.Integer", SetConfig_ValueLeftInteger, yamlConfiguration);
set("Slots.Example.SetConfig.Value.LeftClick.Double", SetConfig_ValueLeftDouble, yamlConfiguration);
set("Slots.Example.SetConfig.Value.LeftClick.List", SetConfig_ValueLeftList, yamlConfiguration);
set("Slots.Example.SetConfig.Value.RightClick.String", SetConfig_ValueRightString, yamlConfiguration);
set("Slots.Example.SetConfig.Value.RightClick.Boolean", SetConfig_ValueRightBoolean, yamlConfiguration);
set("Slots.Example.SetConfig.Value.RightClick.Integer", SetConfig_ValueRightInteger, yamlConfiguration);
set("Slots.Example.SetConfig.Value.RightClick.Double", SetConfig_ValueRightDouble, yamlConfiguration);
set("Slots.Example.SetConfig.Value.RightClick.List", SetConfig_ValueRightList, yamlConfiguration);
set("Slots.Example.SetConfig.PluginReload.Enable", SetConfig_PluginReloadEnable, yamlConfiguration);
set("Slots.Example.SetConfig.PluginReload.Command", SetConfig_PluginReloadCommand, 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

@@ -2,7 +2,6 @@ package de.jatitv.commandguiv2.Spigot.config.config;
import de.jatitv.commandguiv2.Spigot.Main;
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.yamlConfiguration.Config;
@@ -15,8 +14,10 @@ import java.util.Arrays;
public class ConfigCreate {
public static Integer ConfigVersion = 4;
public static void configCreate() {
long long_ = System.currentTimeMillis();
Long long_ = Long.valueOf(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...");
@@ -24,8 +25,15 @@ public class ConfigCreate {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
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----------------------");
}
yamlConfiguration.set("ConfigVersion", ConfigVersion);
Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration);
Config.set("Plugin.Debug", false, yamlConfiguration);
@@ -102,21 +110,6 @@ public class ConfigCreate {
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Material", ItemVersion.getRedWool().getType().toString(), yamlConfiguration);
Config.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration);
Config.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration);
Config.set("Placeholder.True", "&2true", yamlConfiguration);
Config.set("Placeholder.False", "&4false", yamlConfiguration);
Config.set("Sound.Enable", true, yamlConfiguration);
Config.set("Sound.OpenInventory.Enable", true, yamlConfiguration);
@@ -162,6 +155,6 @@ public class ConfigCreate {
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@@ -1,7 +1,6 @@
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;
@@ -12,22 +11,17 @@ 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;
public static Boolean HelpAlias;
public static String language;
public static String Currency;
public static List<String> mainCommands;
public static String Storage;
@@ -75,20 +69,6 @@ public class SelectConfig {
public static String UseItem_Name;
public static List<String> UseItem_Lore;
public static Boolean toggleItemOnOrYesBase64;
public static String toggleItemOnOrYesBase64Value;
public static String toggleItemOnOrYesMaterial;
public static Boolean toggleItemOffOrNoBase64;
public static String toggleItemOffOrNoBase64Value;
public static String toggleItemOffOrNoMaterial;
public static String togglePermTrue;
public static String togglePermFalse;
public static String placeholderTrue;
public static String placeholderFalse;
public static Boolean Sound_Enable = true;
public static Boolean Sound_OpenInventory_Enable = true;
@@ -117,17 +97,8 @@ public class SelectConfig {
public static void onSelect() {
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();
}
}
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) {
DisableUpdateChecker = false;
@@ -169,7 +140,7 @@ public class SelectConfig {
UseItem_Base64value = yamlConfiguration.getString("UseItem.Item.PlayerHead.Base64.Base64Value");
UseItem_PlayerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
UseItem_PlayerName = yamlConfiguration.getString("UseItem.Item.PlayerHead.PlayerName");
UseItem_Name = Replace.replace(Util.getPrefix(), yamlConfiguration.getString("UseItem.Item.Name"));
UseItem_Name = Replace.replace(Util.getPrefix(),yamlConfiguration.getString("UseItem.Item.Name"));
UseItem_Lore = yamlConfiguration.getStringList("UseItem.Item.Lore");
UseItem_GiveOnEveryJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnEveryJoin");
UseItem_GiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnlyOnFirstJoin");
@@ -183,7 +154,7 @@ public class SelectConfig {
UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode");
List<String> gml = new ArrayList<>();
for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")) {
for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")){
gml.add(gm.toUpperCase());
}
UseItemGameModeList = gml;
@@ -193,22 +164,7 @@ public class SelectConfig {
UseItemWorldProtection = yamlConfiguration.getBoolean("Advanced.UseItem.World.Protection.Enable");
UseItemWorldRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled");
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable");
toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value");
toggleItemOnOrYesMaterial = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Material");
toggleItemOffOrNoBase64 = yamlConfiguration.getBoolean("Toggle.Items.OffOrNo.Item.Base64.Enable");
toggleItemOffOrNoBase64Value = yamlConfiguration.getString("Toggle.Items.OffOrNo.Item.Base64.Base64Value");
toggleItemOffOrNoMaterial = yamlConfiguration.getString("Toggle.Items.OffOrNo.Item.Material");
togglePermTrue = yamlConfiguration.getString("Toggle.Permission.Commands.True");
togglePermFalse = yamlConfiguration.getString("Toggle.Permission.Commands.False");
placeholderTrue = yamlConfiguration.getString("Placeholder.True");
placeholderFalse = yamlConfiguration.getString("Placeholder.False");
UseItemWorldList =yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable");
Sound_OpenInventory_Enable = yamlConfiguration.getBoolean("Sound.OpenInventory.Enable");
@@ -224,7 +180,6 @@ 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();
}
@@ -347,13 +302,4 @@ public class SelectConfig {
}
}
private static void setConfigVersion() {
yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -1,176 +0,0 @@
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

@@ -1,146 +0,0 @@
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

@@ -1,72 +0,0 @@
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

@@ -1,122 +0,0 @@
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.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.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.UUID;
public class GuiBuilder {
private static String prefix = Util.getPrefix();
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, function);
item.setItemMeta(itemMeta);
Integer am;
if (function.itemAmount == 0) {
am = 1;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot, item);
}
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, function);
item.setItemMeta(itemMeta);
Integer am;
if (function.itemAmount == 0) {
am = 1;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot, item);
}
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));
} else {
itemMeta.setDisplayName(Replace.replace(prefix, slot.name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, slot.lore, slot.price + " " + SelectConfig.Currency));
}
}
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, function);
item.setItemMeta(itemMeta);
Integer am;
if (function.itemAmount == 0) {
am = 1;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot, item);
}
private static void setBase64(ItemMeta itemMeta, String base64Value) {
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", base64Value == null ? "" : base64Value));
Field profileField;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
}
protected static void base64(Function function,Integer slot, Player player, Inventory inventory) {
base64(function.base64Value, function,slot, player, inventory);
}
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, function);
itemMeta.setOwner(skullName);
item.setItemMeta(itemMeta);
Integer am;
if (function.itemAmount == 0) {
am = 1;
} else am = function.itemAmount;
item.setAmount(am);
inventory.setItem(slot, item);
}
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));
} else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta();
itemMetaglass.setDisplayName(" ");
glass.setItemMeta(itemMetaglass);
glass.setAmount(1);
for (int i = 0; i < 9 * gui.GUI_Lines; i++) {
inventory.setItem(i, glass);
}
}
}

View File

@@ -1,15 +1,16 @@
package de.jatitv.commandguiv2.Spigot.gui;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
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.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
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.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;
@@ -20,14 +21,18 @@ 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.inventory.meta.SkullMeta;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
import java.util.UUID;
public class OpenGUI {
private static Plugin plugin = Main.plugin;
private static String prefix = Util.getPrefix();
public static void openGUI(Player player, String guiString) {
Gui gui = Main.guiHashMap.get(guiString);
public static void openGUI(Player player, Object gui, String guiString) {
Long long_ = Long.valueOf(System.currentTimeMillis());
switch (guiString) {
//case "plugin.PlotSquaredGUI":
@@ -72,69 +77,122 @@ public class OpenGUI {
} 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);
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));
} else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta();
itemMetaglass.setDisplayName(" ");
glass.setItemMeta(itemMetaglass);
glass.setAmount(1);
for (int i = 0; i < 9 * gui.GUI_Lines; i++) {
inventory.setItem(i, glass);
}
}
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 {
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);
}
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 (function.playerHead_Enable) {
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, function.name));
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, function.name));
send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.Slot + 1) + " §7- " + Replace.replace(prefix, slot.Name));
} else {
if (function.base64_Enable) {
GuiBuilder.base64(function, slot.slot, player, inventory);
} else {
if (function.playerWhoHasOpenedTheGUI) {
GuiBuilder.playerHead(function, slot.slot, player, inventory, player.getName());
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
if (slot.Base64_Enable) {
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));
} else {
GuiBuilder.playerHead(function, slot.slot, player, inventory, function.playerName);
itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, slot.Lore, slot.Price + " " + SelectConfig.Currency));
}
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", slot.Base64Value));
Field profileField = null;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
item.setItemMeta(itemMeta);
Integer am;
if (slot.ItemAmount == 0) {
am = 1;
} else am = slot.ItemAmount;
item.setAmount(am);
inventory.setItem(slot.Slot, item);
} else {
if (slot.PlayerWhoHasOpenedTheGUI) {
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));
} else {
itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, slot.Lore, slot.Price + " " + SelectConfig.Currency));
}
itemMeta.setOwner(player.getName());
item.setItemMeta(itemMeta);
Integer am;
if (slot.ItemAmount == 0) {
am = 1;
} else am = slot.ItemAmount;
item.setAmount(am);
inventory.setItem(slot.Slot, item);
} else {
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));
} else {
itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, player, slot.Lore, slot.Price + " " + SelectConfig.Currency));
}
itemMeta.setOwner(slot.PlayerName);
item.setItemMeta(itemMeta);
Integer am;
if (slot.ItemAmount == 0) {
am = 1;
} else am = slot.ItemAmount;
item.setAmount(am);
inventory.setItem(slot.Slot, item);
}
}
}
} else {
GuiBuilder.item(function, slot.slot, player, inventory);
ItemStack item = new ItemStack(Material.valueOf(slot.Item.toUpperCase().replace(".", "_")));
ItemMeta itemMeta = item.getItemMeta();
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));
} else {
itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, slot.Lore, slot.Price + " " + SelectConfig.Currency));
}
item.setItemMeta(itemMeta);
Integer am;
if (slot.ItemAmount == 0) {
am = 1;
} else am = slot.ItemAmount;
item.setAmount(am);
inventory.setItem(slot.Slot, item);
}
}
}
}
}
player.openInventory(inventory);
send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name)));
}
private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) {
if (SelectConfig.toggleItemOnOrYesBase64) {
GuiBuilder.base64(SelectConfig.toggleItemOnOrYesBase64Value, function, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.toggleItemOnOrYesMaterial, function, slot, player, inventory);
}
private static void toggleOff(Function function, Integer slot, Player player, Inventory inventory) {
if (SelectConfig.toggleItemOffOrNoBase64) {
GuiBuilder.base64(SelectConfig.toggleItemOffOrNoBase64Value, function, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.toggleItemOffOrNoMaterial, function, slot, player, inventory);
}
}

View File

@@ -1,162 +0,0 @@
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,157 +0,0 @@
package de.jatitv.commandguiv2.Spigot.objects.functions;
import java.util.List;
public class Function {
public Boolean empty;
public Integer itemAmount;
public Boolean playerHead_Enable;
public Boolean base64_Enable;
public String base64Value;
public Boolean playerWhoHasOpenedTheGUI;
public String playerName;
public String item;
public String name;
public List lore;
public Boolean customSound_Enable;
public Boolean customSound_NoSound;
public String customSound_Sound;
public Boolean cost_Enable;
public Double price;
public Boolean command_Enable;
public Boolean command_BungeeCommand;
public Boolean commandAsConsole;
public Boolean serverChange;
public String serverChangeServer;
public List<String> command;
public Boolean openGUI_Enable;
public String openGUI;
public Boolean togglePermission;
public String togglePermissionPerm;
public Boolean toggleUseItem;
public Boolean message_Enable;
public List<String> message;
public Boolean setConfigEnable;
public String configFilePath;
public String configOptionPath;
public String configOptionPremat;
// public Boolean ConfigChatInput;
public String configStringValueLeft;
public Boolean configBooleanValueLeft;
public Integer configIntegerValueLeft;
public Double configDoubleValueLeft;
public List<String> configListValueLeft;
public String configStringValueRight;
public Boolean configBooleanValueRight;
public Integer configIntegerValueRight;
public Double configDoubleValueRight;
public List<String> configListValueRight;
public Boolean pluginReloadEnable;
public String pluginReloadCommand;
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 configStringValueRight,
Boolean configBooleanValueRight,
Integer configIntegerValueRight,
Double configDoubleValueRight,
List<String> configListValueRight,
Boolean pluginReloadEnable,
String pluginReloadCommand) {
this.empty = empty;
this.itemAmount = itemAmount;
this.playerHead_Enable = playerHead_Enable;
this.base64_Enable = base64Value_Enable;
this.base64Value = base64Value;
this.playerWhoHasOpenedTheGUI = playerWhoHasOpenedTheGUI;
this.playerName = playerName;
this.item = item;
this.name = name;
this.lore = lore;
this.customSound_Enable = customSound_Enable;
this.customSound_NoSound = customSound_NoSound;
this.customSound_Sound = customSound_Sound;
this.cost_Enable = cost_Enable;
this.price = price;
this.command_Enable = command_Enable;
this.command_BungeeCommand = command_BungeeCommand;
this.commandAsConsole = commandAsConsole;
this.command = command;
this.serverChange = serverChange;
this.serverChangeServer = serverChangeServer;
this.openGUI_Enable = openGUI_Enable;
this.openGUI = openGUI;
this.togglePermission = togglePermission;
this.togglePermissionPerm = togglePermissionPerm;
this.toggleUseItem = toggleUseItem;
this.message_Enable = message_Enable;
this.message = message;
this.setConfigEnable = setConfigEnable;
this.configFilePath = configFilePath;
this.configOptionPath = configOptionPath;
this.configOptionPremat = configOptionPremat;
// this.ConfigChatInput = ConfigChatInput;
this.configStringValueLeft = configStringValueLeft;
this.configBooleanValueLeft = configBooleanValueLeft;
this.configIntegerValueLeft = configIntegerValueLeft;
this.configDoubleValueLeft = configDoubleValueLeft;
this.configListValueLeft = configListValueLeft;
this.configStringValueRight = configStringValueRight;
this.configBooleanValueRight = configBooleanValueRight;
this.configIntegerValueRight = configIntegerValueRight;
this.configDoubleValueRight = configDoubleValueRight;
this.configListValueRight = configListValueRight;
this.pluginReloadEnable = pluginReloadEnable;
this.pluginReloadCommand = pluginReloadCommand;
}
}

View File

@@ -1,28 +0,0 @@
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

@@ -2,7 +2,6 @@ package de.jatitv.commandguiv2.Spigot.system;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
@@ -28,10 +27,10 @@ public class Give_UseItem {
if (SelectConfig.UseItem_InventorySlotEnforce){
slot = SelectConfig.UseItem_InventorySlot;
} else {
if (Events.useItemSlotHashMap.get(player)== null) {
if (Select_Database.selectSlot(player) == null) {
slot = SelectConfig.UseItem_InventorySlot;
} else {
slot = Events.useItemSlotHashMap.get(player);
slot = Select_Database.selectSlot(player);
}
}
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {

View File

@@ -2,25 +2,23 @@ package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events_from1_10;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
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.functions.CreateFunctions;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
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.objects.Obj_Select;
import de.jatitv.commandguiv2.Spigot.Objekte.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;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
@@ -45,12 +43,7 @@ public class Load {
if (!new File(Main.getPath(), "config.yml").exists()) {
try {
CreateGUI.configCreate();
} catch (Exception e) {
e.printStackTrace();
}
try {
CreateFunctions.create();
DefaultGUICreate.configCreate();
} catch (Exception e) {
e.printStackTrace();
}
@@ -67,20 +60,16 @@ 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()) {
new Placeholder().register();
}
try {
LanguagesCreate.langCreate();
} catch (Exception e) {
@@ -92,7 +81,7 @@ public class Load {
e.printStackTrace();
}
try {
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
} catch (Exception e) {
e.printStackTrace();
}
@@ -110,7 +99,6 @@ public class Load {
send.console(prefix + " §8-------------------------------");
if (SelectConfig.Storage.equals("MYSQL")) {
MySQL.main();
send.console(prefix + " §2Storage medium §6MySQL §2is used.");
try {
MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
@@ -128,7 +116,7 @@ public class Load {
}
} else {
send.console(prefix + " §2Storage medium §6YML §2is used.");
if (SelectConfig.Debug) send.console(prefix + " §6Storage medium §2YML §6is used.");
}
if (Main.PaPi) {
send.console(prefix + " §2PlaceholderAPI successfully connected!");
@@ -142,14 +130,17 @@ public class Load {
e.printStackTrace();
}
// Main.plugin.getCommand("commandguiadmin").setExecutor(new CmdExecuter_Admin());
// send.debug(plugin, "Commandregister: commandguiadmin");
if (SelectConfig.HelpAlias) {
Main.plugin.getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
send.debug(plugin, "CommandRegister: commandguihelp");
send.debug(plugin, "Commandregister: commandguihelp");
}
Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUITab());
send.debug(plugin, "CommandRegister: commandgui");
Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUI());
send.debug(plugin, "Commandregister: commandgui");
Main.plugin.getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem());
send.debug(plugin, "CommandRegister: commandgui-item");
send.debug(plugin, "Commandregister: commandgui-item");
try {
AliasRegister.onRegister();
@@ -157,6 +148,7 @@ public class Load {
e.printStackTrace();
}
Bukkit.getServer().getPluginManager().registerEvents(new GUI_Listener(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new PluginEvent(), plugin);
@@ -166,6 +158,7 @@ public class Load {
Bukkit.getServer().getPluginManager().registerEvents(new Events_from1_10(), plugin);
}
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
Metrics.Bstats();
Main.addonLoad();

View File

@@ -1,56 +0,0 @@
// This claas was created by JaTiTV
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
public class Placeholder extends PlaceholderExpansion {
@Override
public String getIdentifier() {
return "commandgui";
}
@Override
public String getAuthor() {
return Main.plugin.getDescription().getAuthors().toString();
}
@Override
public String getVersion() {
return Main.plugin.getDescription().getVersion();
}
@Override
public boolean canRegister() {
return true;
}
@Override
public boolean persist() {
return true;
}
@Override
public String onPlaceholderRequest(Player p, String params) {
if (params.contains("useitem_boolean")) {
return Events.useItemHashMap.get(p).toString();
}
if (params.contains("useitem")) {
if (Events.useItemHashMap.get(p)) {
return SelectConfig.placeholderTrue;
} else return SelectConfig.placeholderFalse;
}
if (params.contains("slot")){
return Events.useItemSlotHashMap.get(p).toString();
}
return null;
}
}

View File

@@ -1,24 +1,20 @@
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Main;
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 de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission;
public class RegisterPermissions {
public static void onPermRegister() {
for (Gui gui : Main.guiHashMap.values()) {
for (Object 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.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));
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)));
}
}
}

View File

@@ -4,6 +4,7 @@ import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.plugin.Plugin;
import java.sql.*;
import java.time.ZoneId;
@@ -151,6 +152,6 @@ public class MySQL {
}
public static void close() {
if (ds != null) ds.close();
ds.close();
}
}

View File

@@ -1,6 +1,5 @@
package de.jatitv.commandguiv2.Spigot.system.database;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import org.bukkit.entity.Player;
@@ -22,7 +21,6 @@ public class Select_Database {
}
public static void setItemStatusTrue(Player player) {
Events.useItemHashMap.replace(player, true);
if (SelectConfig.Storage.equals("MYSQL")) {
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';");
@@ -32,7 +30,6 @@ public class Select_Database {
}
public static void setItemStatusFalse(Player player) {
Events.useItemHashMap.replace(player, false);
if (SelectConfig.Storage.equals("MYSQL")) {
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()

View File

@@ -11,7 +11,7 @@ import java.io.IOException;
public class YML {
private static final Plugin plugin = Main.plugin;
private static 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,7 +1,6 @@
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;
@@ -32,8 +31,4 @@ public class Util {
public static String getDiscord() {
return Discord;
}
public static Integer getConfigVersion() {
return configVersion;
}
}

View File

@@ -1,11 +1,10 @@
package de.jatitv.commandguiv2.api;
import de.jatitv.commandguiv2.Spigot.Listener.ItemChange;
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.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate;
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;
@@ -43,11 +42,11 @@ public class CGuiAPI {
}
public static Boolean selectPlayerItemEnable(Player player) {
return Events.useItemHashMap.get(player);
return Select_Database.selectItemStatus(player);
}
public static Integer selectPlayerItemSlot(Player player) {
return Events.useItemSlotHashMap.get(player);
return Select_Database.selectSlot(player);
}
public static void setPlayerItemEnable(Player player, Boolean value) {
@@ -81,7 +80,7 @@ public class CGuiAPI {
public static void createDefaultGUI(CommandSender sender) {
if (sender.hasPermission("commandgui.admin")) {
CreateGUI.configCreate();
DefaultGUICreate.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

@@ -1,4 +1,5 @@
Manifest-Version: 1.0
Main-Class:
Class-Path: PlugmanGUI-3.0.jar spigot-1.8r3.jar spigot-1.9r1.jar spigot-
1.15r1.jar T2CodeLib-10.3.jar spigot-1.18r1.jar bungee-1615.jar spigot-
1.9r2.jar spigot-1.16r3.jar spigot-1.14r1.jar slf4j-api-1.7.25.jar Luck

View File

@@ -1,5 +1,5 @@
Slot:
Function:
Functions:
Item:
Empty: false
Amount: 1
@@ -49,6 +49,8 @@ Slot:
Enable: true
Message:
- '&6You can find more information on Discord: &ehttp://dc.t2code.net'
Permission:
Required: false
SetConfig:
Enable: false
File:

View File

@@ -14,15 +14,7 @@ Slots:
Slot: 4
Enable: true
Function: SupportDiscord
Permission:
Required: false
See: ''
Use: ''
UseItem:
Slot: 6
Enable: true
Function: UseItem
Permission:
Required: false
See: ''
Use: ''