Compare commits

..

2 Commits

Author SHA1 Message Date
b45895dff8 Update Util.java 2022-06-08 05:14:56 +02:00
c43a5fd90c 2.8.2
Changes:
- The structure of config.yml has been slightly changed (nothing needs to be changed as the settings paths remain the same)
- The code structure has been rebuilt / improved

Fix:
- Fixed an error that occurred when a player joined the sever and immediately left.
2022-06-08 05:11:26 +02:00
40 changed files with 857 additions and 502 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
<packaging>jar</packaging>
<name>CommandGUI</name>

View File

@ -4,7 +4,7 @@ package de.jatitv.commandguiv2.Spigot;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.system.Load;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Spigot.database.MySQL;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -18,7 +18,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class Main extends JavaPlugin {
@ -50,8 +49,6 @@ public final class Main extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
// Plugin startup logic
Logger logger = this.getLogger();
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
@ -72,10 +69,12 @@ public final class Main extends JavaPlugin {
PlotSquaredGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
}
if (PluginCheck.luckyBox()) {
LuckyBox = true;
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
}
if (PluginCheck.plugManGUI()) {
PlugManGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlugManGUI"));

View File

@ -30,7 +30,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
Player player = (Player) sender;
Commands.gui(player);
} else {
if (args[0].equals(SelectConfig.adminSubCommand)) {
if (args[0].equals(SelectConfig.getAdminSubCommand())) {
if (args.length == 1) {
Help.sendHelp(sender, prefix);
return false;
@ -106,7 +106,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
List<String> list = new ArrayList<>();
Tab.tab(list, sender, 0, args, arg1);
Tab.tab(list, sender, 0, SelectConfig.adminSubCommand, 1, args, arg2);
Tab.tab(list, sender, 0, SelectConfig.getAdminSubCommand(), 1, args, arg2);
Tab.tab(list, sender, 1, "give", 2, args, "commandgui.giveitem.other", true);
// if (args.length == 1) {

View File

@ -22,13 +22,13 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
Player player = (Player) sender;
if (sender.hasPermission("commandgui.useitem.toggle")) {
if (args.length == 0) {
if (SelectConfig.UseItem_AllowToggle) {
if (SelectConfig.getUseItem_AllowToggle()) {
Help.sendGUIItemHelp(sender);
} else send.sender(sender, "§4UseItem toggle is disabled!");// todo
} else {
if (args.length == 1 || args.length == 2) {
if (sender instanceof Player) {
if (SelectConfig.UseItem_AllowToggle) {
if (SelectConfig.getUseItem_AllowToggle()) {
switch (args[0].toLowerCase()) {
case "on":
Commands.itemOn(player);
@ -65,7 +65,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("on", "commandgui.useitem.toggle");
put("off", "commandgui.useitem.toggle");
if (SelectConfig.UseItem_AllowSetSlot) {
if (SelectConfig.getUseItem_AllowSetSlot()) {
put("slot", "commandgui.useitem.toggle");
}
}};
@ -74,7 +74,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>();
if (sender instanceof Player) {
if (SelectConfig.UseItem_AllowToggle) {
if (SelectConfig.getUseItem_AllowToggle()) {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {

View File

@ -1,17 +1,19 @@
package de.jatitv.commandguiv2.Spigot.cmdManagement;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.useItem.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.cmdManagement.register.AliasRegister;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.UseItem;
import de.jatitv.commandguiv2.Spigot.useItem.UseItem;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.sound.Sound;
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
@ -62,9 +64,9 @@ public class Commands {
Main.plugin.reloadConfig();
CmdExecuter_GUI.arg1.clear();
CmdExecuter_GUI.arg1.put(SelectConfig.adminSubCommand, "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
CmdExecuter_GUI.arg1.put(SelectConfig.getAdminSubCommand(), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) {
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.getStorage())) {
if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!");
send.warning(Main.plugin, "You have changed the storage medium! To apply this change, you must restart the server!");
}
@ -86,7 +88,7 @@ public class Commands {
e.printStackTrace();
}
if (SelectConfig.Bungee) {
if (SelectConfig.getBungee()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee");
}
@ -100,25 +102,20 @@ public class Commands {
public static void give(CommandSender sender, Player target) {
if (Bukkit.getPlayer(target.getName()) != null) {
UseItem.giveUseItem(target);
send.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.UseItem_Name));
send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.UseItem_Name));
if (SelectConfig.Sound_Give_Enable && SelectConfig.Sound_Enable) {
target.playSound(target.getLocation(), SelectConfig.Sound_Give, 3, 1);
}
send.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.getUseItem_Name()));
send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.getUseItem_Name()));
Sound.play(target, SoundEnum.Give);
} else {
sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName()));
if (SelectConfig.Sound_PlayerNotFound_Enable && SelectConfig.Sound_Enable) {
if (sender instanceof Player)
((Player) sender).playSound(((Player) sender).getLocation(), SelectConfig.Sound_PlayerNotFound, 3, 1);
}
if (sender instanceof Player) Sound.play((Player) sender, SoundEnum.PlayerNotFound);
}
}
public static void itemOn(Player player) {
UseItem.removeItem(player);
Integer slot = null;
if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot;
if (SelectConfig.getUseItem_InventorySlotEnforce()) {
slot = SelectConfig.getUseItem_InventorySlot();
} else {
slot = Events.useItemSlotHashMap.get(player.getName());
}
@ -140,9 +137,7 @@ public class Commands {
send.player(player, SelectMessages.ItemON);
} else {
send.player(player, SelectMessages.NoInventorySpace);
if (SelectConfig.Sound_NoInventorySpace_Enable && SelectConfig.Sound_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_NoInventorySpace, 3, 1);
}
Sound.play(player,SoundEnum.NoInventorySpace);
}
}
}
@ -154,7 +149,7 @@ public class Commands {
}
public static void onSetSlot(Player player, Integer setSlot) {
if (!SelectConfig.UseItem_AllowSetSlot) {
if (!SelectConfig.getUseItem_AllowSetSlot()) {
send.player(player, Util.getPrefix() + " §4Function disabled");
return;
}
@ -175,7 +170,7 @@ public class Commands {
}
}
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) {
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(setSlot - 1) != null) {
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
return;
}
@ -192,11 +187,11 @@ public class Commands {
}
public static void gui(Player player) {
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
if (Main.guiHashMap.containsKey(SelectConfig.getDefaultGUI())) {
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI());
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, SelectConfig.DefaultGUI, true);
OpenGUI.openGUI(player, SelectConfig.getDefaultGUI(), true);
} else send.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
.replace("[perm]", "commandgui.command"));
} else send.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));

View File

@ -14,7 +14,7 @@ public class Help {
private static String prefix = Util.getPrefix();
public static void sendHelp(CommandSender sender, String Prefix) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI());
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
cgui(sender, gui);

View File

@ -93,47 +93,6 @@ public class ConfigCreate {
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration);
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
Config.set("Advanced.UseItem.World.Change.Enable", true, yamlConfiguration);
Config.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
/*
Config.set("Advanced.UseItem.ItemBlockBlacklist", Arrays.asList("CHEST", "TRAPPED_CHEST", "FURNACE", "NOTE_BLOCK",
"CRAFTING_TABLE", "ENDER_CHEST", "ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER",
"BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE", "SMITHING_TABLE", "STONECUTTER",
"HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR",
"STONE_BUTTON", "OAK_BUTTON", "SPRUCE_BUTTON", "BIRCH_BUTTON", "JUNGLE_BUTTON", "ACACIA_BUTTON", "DARK_OAK_BUTTON", "CRIMSON_BUTTON",
"IRON_DOOR", "OAK_DOOR", "SPRUCE_DOOR", "BIRCH_DOOR", "JUNGLE_DOOR", "ACACIA_DOOR", "DARK_OAK_DOOR", "CRIMSON_DOOR", "WARPED_DOOR",
"OAK_FENCE", "SPRUCE_FENCE", "BIRCH_FENCE", "JUNGLE_FENCE", "ACACIA_FENCE", "DARK_OAK_FENCE", "CRIMSON_FENCE", "WARPED_FENCE", "NETHER_BRICK_FENCE"), yamlConfiguration);
*/
if (!yamlConfiguration.contains("Advanced.UseItem.ItemBlockBlacklist")) {
List<String> materialList = Arrays.asList("BUTTON", "DOOR", "FENCE", "CHEST", "FURNACE", "NOTE_BLOCK", "CRAFTING_TABLE", "WORKBENCH",
"ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER", "BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE",
"SMITHING_TABLE", "STONECUTTER", "HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR", "BREWING_STAND", "TRAPDOOR", "BEACON"
);
List<String> materialBlacklist = new ArrayList<>();
for (Material material : Material.values()) {
for (String target : materialList) {
if (material.toString().contains(target)) materialBlacklist.add(material.toString());
}
}
Config.set("Advanced.UseItem.ItemBlockBlacklist", materialBlacklist, yamlConfiguration);
}
Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
if (Main.legacy) {
@ -192,6 +151,35 @@ public class ConfigCreate {
Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
} else Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
Config.set("Advanced.UseItem.World.Change.Enable", true, yamlConfiguration);
Config.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
if (!yamlConfiguration.contains("Advanced.UseItem.ItemBlockBlacklist")) {
List<String> materialList = Arrays.asList("BUTTON", "DOOR", "FENCE", "CHEST", "FURNACE", "NOTE_BLOCK", "CRAFTING_TABLE", "WORKBENCH",
"ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER", "BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE",
"SMITHING_TABLE", "STONECUTTER", "HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR", "BREWING_STAND", "TRAPDOOR", "BEACON"
);
List<String> materialBlacklist = new ArrayList<>();
for (Material material : Material.values()) {
for (String target : materialList) {
if (material.toString().contains(target)) materialBlacklist.add(material.toString());
}
}
Config.set("Advanced.UseItem.ItemBlockBlacklist", materialBlacklist, yamlConfiguration);
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {

View File

@ -3,7 +3,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;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@ -17,102 +16,6 @@ import java.util.ArrayList;
import java.util.List;
public class SelectConfig {
public static Boolean Debug;
public static Boolean HelpAlias;
public static String adminSubCommand;
public static String language;
public static String Currency;
public static String storage;
public static Boolean Bungee;
public static String thisServer;
public static String DefaultGUI;
public static Boolean UseItem_Enable;
public static Boolean UseItem_AllowToggle;
public static Boolean UseItem_AllowSetSlot;
public static Boolean UseItem_GiveOnEveryJoin;
public static Boolean UseItem_GiveOnlyOnFirstJoin;
public static Boolean UseItem_ServerChange;
public static Boolean Cursor_ToGUIItem_OnLogin;
public static Boolean Cursor_ToGUIItem_OnlyOnFirstLogin;
public static Boolean UseItem_BlockMoveAndDrop;
public static String UseItem_OpenGUI;
public static Boolean UseItem_Permission;
public static Boolean UseItem_KeepAtCommandClear;
public static Boolean UseItemGameModeChangeEnable;
public static int UseItemGameModeChangeDelayInTicks;
public static Boolean UseItemGameModeProtection;
public static Boolean UseItemGameModeRemoveItemWhenItIsDisabled;
public static String UseItemGameModeMode;
public static List<String> UseItemGameModeList;
public static Boolean UseItemWorldChangeEnable;
public static int UseItemWorldChangeDelayInTicks;
public static Boolean UseItemWorldProtection;
public static Boolean UseItemWorldRemoveItemWhenItIsDisabled;
public static String UseItemWorldMode;
public static List<String> UseItemWorldList;
public static List<String> UseItemItemBlockBlacklist;
public static Boolean disableInfoBySneak = false;
public static Boolean UseItem_InventorySlot_FreeSlot;
public static Integer UseItem_InventorySlot;
public static Boolean UseItem_InventorySlotEnforce;
public static String UseItem_Material;
public static Boolean UseItem_PlayerHead_Enable;
public static Boolean UseItem_Base64_Enable;
public static String UseItem_Base64value;
public static Boolean UseItem_PlayerWhoHasOpenedTheGUI;
public static String UseItem_PlayerName;
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;
public static Sound Sound_OpenInventory;
public static String Sound_OpenInventory_input;
public static Boolean Sound_Click_Enable = true;
public static Sound Sound_Click;
public static String Sound_Click_input;
public static Boolean Sound_NoMoney_Enable = true;
public static Sound Sound_NoMoney;
public static String Sound_NoMoney_input;
public static Boolean Sound_NoInventorySpace_Enable = true;
public static Sound Sound_NoInventorySpace;
public static String Sound_NoInventorySpace_input;
public static Boolean Sound_Give_Enable = true;
public static Sound Sound_Give;
public static String Sound_Give_input;
public static Boolean Sound_PlayerNotFound_Enable = true;
public static Sound Sound_PlayerNotFound;
public static String Sound_PlayerNotFound_input;
public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
@ -136,12 +39,12 @@ public class SelectConfig {
DefaultGUI = yamlConfiguration.getString("Plugin.DefaultGUI");
storage = yamlConfiguration.getString("Storage.Type").toUpperCase();
MySQL.ip = yamlConfiguration.getString("Storage.MySQL.IP");
MySQL.port = yamlConfiguration.getInt("Storage.MySQL.Port");
MySQL.database = yamlConfiguration.getString("Storage.MySQL.Database");
MySQL.user = yamlConfiguration.getString("Storage.MySQL.User");
MySQL.password = yamlConfiguration.getString("Storage.MySQL.Password");
MySQL.SSL = yamlConfiguration.getBoolean("Storage.MySQL.SSL");
mysqlIp = yamlConfiguration.getString("Storage.MySQL.IP");
mysqlPort = yamlConfiguration.getInt("Storage.MySQL.Port");
mysqlDatabase = yamlConfiguration.getString("Storage.MySQL.Database");
mysqlUser = yamlConfiguration.getString("Storage.MySQL.User");
mysqlPassword = yamlConfiguration.getString("Storage.MySQL.Password");
mysqlSSL = yamlConfiguration.getBoolean("Storage.MySQL.SSL");
Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
thisServer = yamlConfiguration.getString("BungeeCord.ThisServer");
@ -172,31 +75,6 @@ public class SelectConfig {
Cursor_ToGUIItem_OnlyOnFirstLogin = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin");
UseItem_ServerChange = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange");
UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Change.Enable");
UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameMode.Change.DelayInTicks");
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable");
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")) {
gml.add(gm.toUpperCase());
}
UseItemGameModeList = gml;
UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable");
UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks");
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");
if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) {
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
}
UseItemItemBlockBlacklist = yamlConfiguration.getStringList("Advanced.UseItem.ItemBlockBlacklist");
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");
@ -225,6 +103,31 @@ 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(".", "_"));
UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Change.Enable");
UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameMode.Change.DelayInTicks");
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable");
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")) {
gml.add(gm.toUpperCase());
}
UseItemGameModeList = gml;
UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable");
UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks");
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");
if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) {
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
}
UseItemItemBlockBlacklist = yamlConfiguration.getStringList("Advanced.UseItem.ItemBlockBlacklist");
}
@ -358,4 +261,431 @@ public class SelectConfig {
e.printStackTrace();
}
}
private static Boolean Debug;
private static Boolean HelpAlias;
private static String adminSubCommand;
private static String language;
private static String Currency;
private static String storage;
private static String mysqlIp;
private static Integer mysqlPort;
private static String mysqlDatabase;
private static String mysqlUser;
private static String mysqlPassword;
private static Boolean mysqlSSL;
private static Boolean Bungee;
private static String thisServer;
private static String DefaultGUI;
private static Boolean UseItem_Enable;
private static Boolean UseItem_AllowToggle;
private static Boolean UseItem_AllowSetSlot;
private static Boolean UseItem_GiveOnEveryJoin;
private static Boolean UseItem_GiveOnlyOnFirstJoin;
private static Boolean UseItem_ServerChange;
private static Boolean Cursor_ToGUIItem_OnLogin;
private static Boolean Cursor_ToGUIItem_OnlyOnFirstLogin;
private static Boolean UseItem_BlockMoveAndDrop;
private static String UseItem_OpenGUI;
private static Boolean UseItem_Permission;
private static Boolean UseItem_KeepAtCommandClear;
private static Boolean UseItemGameModeChangeEnable;
private static int UseItemGameModeChangeDelayInTicks;
private static Boolean UseItemGameModeProtection;
private static Boolean UseItemGameModeRemoveItemWhenItIsDisabled;
private static String UseItemGameModeMode;
private static List<String> UseItemGameModeList;
private static Boolean UseItemWorldChangeEnable;
private static int UseItemWorldChangeDelayInTicks;
private static Boolean UseItemWorldProtection;
private static Boolean UseItemWorldRemoveItemWhenItIsDisabled;
private static String UseItemWorldMode;
private static List<String> UseItemWorldList;
private static List<String> UseItemItemBlockBlacklist;
private static Boolean disableInfoBySneak = false;
private static Boolean UseItem_InventorySlot_FreeSlot;
private static Integer UseItem_InventorySlot;
private static Boolean UseItem_InventorySlotEnforce;
private static String UseItem_Material;
private static Boolean UseItem_PlayerHead_Enable;
private static Boolean UseItem_Base64_Enable;
private static String UseItem_Base64value;
private static Boolean UseItem_PlayerWhoHasOpenedTheGUI;
private static String UseItem_PlayerName;
private static String UseItem_Name;
private static List<String> UseItem_Lore;
private static Boolean toggleItemOnOrYesBase64;
private static String toggleItemOnOrYesBase64Value;
private static String toggleItemOnOrYesMaterial;
private static Boolean toggleItemOffOrNoBase64;
private static String toggleItemOffOrNoBase64Value;
private static String toggleItemOffOrNoMaterial;
private static String togglePermTrue;
private static String togglePermFalse;
private static String placeholderTrue;
private static String placeholderFalse;
private static Boolean Sound_Enable = true;
private static Boolean Sound_OpenInventory_Enable = true;
private static Sound Sound_OpenInventory;
private static String Sound_OpenInventory_input;
private static Boolean Sound_Click_Enable = true;
private static Sound Sound_Click;
private static String Sound_Click_input;
private static Boolean Sound_NoMoney_Enable = true;
private static Sound Sound_NoMoney;
private static String Sound_NoMoney_input;
private static Boolean Sound_NoInventorySpace_Enable = true;
private static Sound Sound_NoInventorySpace;
private static String Sound_NoInventorySpace_input;
private static Boolean Sound_Give_Enable = true;
private static Sound Sound_Give;
private static String Sound_Give_input;
private static Boolean Sound_PlayerNotFound_Enable = true;
private static Sound Sound_PlayerNotFound;
private static String Sound_PlayerNotFound_input;
public static Boolean getDebug() {
return Debug;
}
public static Boolean getHelpAlias() {
return HelpAlias;
}
public static String getAdminSubCommand() {
return adminSubCommand;
}
public static String getLanguage() {
return language;
}
public static String getCurrency() {
return Currency;
}
public static String getStorage() {
return storage;
}
public static String getMysqlIp() {
return mysqlIp;
}
public static Integer getMysqlPort() {
return mysqlPort;
}
public static String getMysqlDatabase() {
return mysqlDatabase;
}
public static String getMysqlUser() {
return mysqlUser;
}
public static String getMysqlPassword() {
return mysqlPassword;
}
public static Boolean getMysqlSSL() {
return mysqlSSL;
}
public static Boolean getBungee() {
return Bungee;
}
public static String getThisServer() {
return thisServer;
}
public static String getDefaultGUI() {
return DefaultGUI;
}
public static Boolean getUseItem_Enable() {
return UseItem_Enable;
}
public static Boolean getUseItem_AllowToggle() {
return UseItem_AllowToggle;
}
public static Boolean getUseItem_AllowSetSlot() {
return UseItem_AllowSetSlot;
}
public static Boolean getUseItem_GiveOnEveryJoin() {
return UseItem_GiveOnEveryJoin;
}
public static Boolean getUseItem_GiveOnlyOnFirstJoin() {
return UseItem_GiveOnlyOnFirstJoin;
}
public static Boolean getUseItem_ServerChange() {
return UseItem_ServerChange;
}
public static Boolean getCursor_ToGUIItem_OnLogin() {
return Cursor_ToGUIItem_OnLogin;
}
public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() {
return Cursor_ToGUIItem_OnlyOnFirstLogin;
}
public static Boolean getUseItem_BlockMoveAndDrop() {
return UseItem_BlockMoveAndDrop;
}
public static String getUseItem_OpenGUI() {
return UseItem_OpenGUI;
}
public static Boolean getUseItem_Permission() {
return UseItem_Permission;
}
public static Boolean getUseItem_KeepAtCommandClear() {
return UseItem_KeepAtCommandClear;
}
public static Boolean getUseItemGameModeChangeEnable() {
return UseItemGameModeChangeEnable;
}
public static int getUseItemGameModeChangeDelayInTicks() {
return UseItemGameModeChangeDelayInTicks;
}
public static Boolean getUseItemGameModeProtection() {
return UseItemGameModeProtection;
}
public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() {
return UseItemGameModeRemoveItemWhenItIsDisabled;
}
public static String getUseItemGameModeMode() {
return UseItemGameModeMode;
}
public static List<String> getUseItemGameModeList() {
return UseItemGameModeList;
}
public static Boolean getUseItemWorldChangeEnable() {
return UseItemWorldChangeEnable;
}
public static int getUseItemWorldChangeDelayInTicks() {
return UseItemWorldChangeDelayInTicks;
}
public static Boolean getUseItemWorldProtection() {
return UseItemWorldProtection;
}
public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() {
return UseItemWorldRemoveItemWhenItIsDisabled;
}
public static String getUseItemWorldMode() {
return UseItemWorldMode;
}
public static List<String> getUseItemWorldList() {
return UseItemWorldList;
}
public static List<String> getUseItemItemBlockBlacklist() {
return UseItemItemBlockBlacklist;
}
public static Boolean getDisableInfoBySneak() {
return disableInfoBySneak;
}
public static Boolean getUseItem_InventorySlot_FreeSlot() {
return UseItem_InventorySlot_FreeSlot;
}
public static Integer getUseItem_InventorySlot() {
return UseItem_InventorySlot;
}
public static Boolean getUseItem_InventorySlotEnforce() {
return UseItem_InventorySlotEnforce;
}
public static String getUseItem_Material() {
return UseItem_Material;
}
public static Boolean getUseItem_PlayerHead_Enable() {
return UseItem_PlayerHead_Enable;
}
public static Boolean getUseItem_Base64_Enable() {
return UseItem_Base64_Enable;
}
public static String getUseItem_Base64value() {
return UseItem_Base64value;
}
public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() {
return UseItem_PlayerWhoHasOpenedTheGUI;
}
public static String getUseItem_PlayerName() {
return UseItem_PlayerName;
}
public static String getUseItem_Name() {
return UseItem_Name;
}
public static List<String> getUseItem_Lore() {
return UseItem_Lore;
}
public static Boolean getToggleItemOnOrYesBase64() {
return toggleItemOnOrYesBase64;
}
public static String getToggleItemOnOrYesBase64Value() {
return toggleItemOnOrYesBase64Value;
}
public static String getToggleItemOnOrYesMaterial() {
return toggleItemOnOrYesMaterial;
}
public static Boolean getToggleItemOffOrNoBase64() {
return toggleItemOffOrNoBase64;
}
public static String getToggleItemOffOrNoBase64Value() {
return toggleItemOffOrNoBase64Value;
}
public static String getToggleItemOffOrNoMaterial() {
return toggleItemOffOrNoMaterial;
}
public static String getTogglePermTrue() {
return togglePermTrue;
}
public static String getTogglePermFalse() {
return togglePermFalse;
}
public static String getPlaceholderTrue() {
return placeholderTrue;
}
public static String getPlaceholderFalse() {
return placeholderFalse;
}
public static Boolean getSound_Enable() {
return Sound_Enable;
}
public static Boolean getSound_OpenInventory_Enable() {
return Sound_OpenInventory_Enable;
}
public static Sound getSound_OpenInventory() {
return Sound_OpenInventory;
}
public static String getSound_OpenInventory_input() {
return Sound_OpenInventory_input;
}
public static Boolean getSound_Click_Enable() {
return Sound_Click_Enable;
}
public static Sound getSound_Click() {
return Sound_Click;
}
public static String getSound_Click_input() {
return Sound_Click_input;
}
public static Boolean getSound_NoMoney_Enable() {
return Sound_NoMoney_Enable;
}
public static Sound getSound_NoMoney() {
return Sound_NoMoney;
}
public static String getSound_NoMoney_input() {
return Sound_NoMoney_input;
}
public static Boolean getSound_NoInventorySpace_Enable() {
return Sound_NoInventorySpace_Enable;
}
public static Sound getSound_NoInventorySpace() {
return Sound_NoInventorySpace;
}
public static String getSound_NoInventorySpace_input() {
return Sound_NoInventorySpace_input;
}
public static Boolean getSound_Give_Enable() {
return Sound_Give_Enable;
}
public static Sound getSound_Give() {
return Sound_Give;
}
public static String getSound_Give_input() {
return Sound_Give_input;
}
public static Boolean getSound_PlayerNotFound_Enable() {
return Sound_PlayerNotFound_Enable;
}
public static Sound getSound_PlayerNotFound() {
return Sound_PlayerNotFound;
}
public static String getSound_PlayerNotFound_input() {
return Sound_PlayerNotFound_input;
}
}

View File

@ -2,14 +2,13 @@ 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.Spigot.system.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.system.FunctionVoteEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
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;

View File

@ -1,11 +1,10 @@
package de.jatitv.commandguiv2.Spigot.config.functions;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.system.FunctionVoteEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
import de.jatitv.commandguiv2.Util;
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;

View File

@ -88,17 +88,17 @@ public class SelectMessages {
File msg;
msg = new File(Main.getPath(), "languages/" + SelectConfig.language + "_messages.yml");
msg = new File(Main.getPath(), "languages/" + SelectConfig.getLanguage() + "_messages.yml");
if (!msg.isFile()) {
send.console(Prefix);
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.console(Prefix + " §4The selected §c" + SelectConfig.language + " §4language file was not found.");
send.console(Prefix + " §4The selected §c" + SelectConfig.getLanguage() + " §4language file was not found.");
send.console(Prefix + " §6The default language §eEnglish §6is used!");
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.console(Prefix);
msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
selectMSG = "english";
} else selectMSG = SelectConfig.language;
} else selectMSG = SelectConfig.getLanguage();
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
VaultNotSetUp = select("Plugin.VaultNotSetUp", yamlConfiguration_msg);

View File

@ -1,4 +1,4 @@
package de.jatitv.commandguiv2.Spigot.system.database;
package de.jatitv.commandguiv2.Spigot.database;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@ -6,7 +6,6 @@ import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.Bukkit;
import java.sql.*;
import java.time.ZoneId;
@ -15,13 +14,7 @@ import java.util.Calendar;
import java.util.HashMap;
public class MySQL {
public static String ip = "localhost";
public static Integer port = 3306;
public static String database;
public static String user = "root";
public static String password = "";
protected static String url;
public static Boolean SSL;
private static final HikariConfig config = new HikariConfig();
private static HikariDataSource ds;
@ -31,9 +24,11 @@ public class MySQL {
ZoneId timeZone = now.getTimeZone().toZoneId();
send.debug(Main.plugin, "Server TimeZone is : " + timeZone);
try {
config.setJdbcUrl("jdbc:mysql://" + ip + ":" + port + "/" + database + "?useJDBCCompliantTimezoneShift=true&allowMultiQueries=true&useLegacyDatetimeCode=false&autoReconnect=true&serverTimezone=" + timeZone + "&useSSL=" + SSL);
config.setUsername(user);
config.setPassword(password);
config.setJdbcUrl("jdbc:mysql://" + SelectConfig.getMysqlIp() + ":" + SelectConfig.getMysqlPort() + "/" + SelectConfig.getMysqlDatabase()
+ "?useJDBCCompliantTimezoneShift=true&allowMultiQueries=true&useLegacyDatetimeCode=false&autoReconnect=true&serverTimezone=" + timeZone
+ "&useSSL=" + SelectConfig.getMysqlSSL());
config.setUsername(SelectConfig.getMysqlUser());
config.setPassword(SelectConfig.getMysqlPassword());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
@ -44,7 +39,7 @@ public class MySQL {
send.error(Main.plugin, ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms");
}
if (SelectConfig.Debug || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) {
if (SelectConfig.getDebug() || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) {
try {
send.error(Main.plugin, "MySQL DEBUG:");
Connection con = ds.getConnection();

View File

@ -1,4 +1,4 @@
package de.jatitv.commandguiv2.Spigot.system.database;
package de.jatitv.commandguiv2.Spigot.database;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Util;

View File

@ -1,20 +1,21 @@
package de.jatitv.commandguiv2.Spigot.system.database;
package de.jatitv.commandguiv2.Spigot.database;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.useItem.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.enums.StorageEnum;
import org.bukkit.entity.Player;
import java.sql.SQLException;
public class SelectDatabase {
private static StorageType Storage;
private static StorageEnum Storage;
public static StorageType getStorage() {
public static StorageEnum getStorage() {
return Storage;
}
public static void setStorage(StorageType storage) {
public static void setStorage(StorageEnum storage) {
Storage = storage;
}

View File

@ -1,8 +1,7 @@
package de.jatitv.commandguiv2.Spigot.system.database;
package de.jatitv.commandguiv2.Spigot.database;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package de.jatitv.commandguiv2.Spigot.system;
package de.jatitv.commandguiv2.Spigot.enums;
public enum EcoEnum {
VAULT, MONEY,

View File

@ -1,5 +1,5 @@
package de.jatitv.commandguiv2.Spigot.system;
package de.jatitv.commandguiv2.Spigot.enums;
public enum FunctionItemEnum {
REMOVE, ADD

View File

@ -1,4 +1,4 @@
package de.jatitv.commandguiv2.Spigot.system;
package de.jatitv.commandguiv2.Spigot.enums;
public enum FunctionVoteEnum {
REMOVE, ADD

View File

@ -0,0 +1,10 @@
package de.jatitv.commandguiv2.Spigot.enums;
public enum SoundEnum {
OpenInventory,
Click,
NoMoney,
NoInventorySpace,
Give,
PlayerNotFound
}

View File

@ -0,0 +1,7 @@
package de.jatitv.commandguiv2.Spigot.enums;
public enum StorageEnum {
MYSQL,
SQLITE,
YML
}

View File

@ -1,17 +1,18 @@
package de.jatitv.commandguiv2.Spigot.listener;
package de.jatitv.commandguiv2.Spigot.gui;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.listener.ServerChange;
import de.jatitv.commandguiv2.Spigot.useItem.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.system.Bungee_Sender_Reciver;
import de.jatitv.commandguiv2.Spigot.listener.Bungee_Sender_Reciver;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.FunctionVoteEnum;
import de.jatitv.commandguiv2.Spigot.system.Placeholder;
import de.jatitv.commandguiv2.Spigot.sound.Sound;
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.eco.Eco;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
@ -19,21 +20,18 @@ import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
public class GUIListener implements Listener {
@ -103,7 +101,7 @@ public class GUIListener implements Listener {
if (function.setConfigEnable) setConfig(function, player, e);
if (function.functionVotePoints) votePoints(e, function, player);
if (function.functionItem) item(function, player);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(function, slot, player, gui);
Sound.play(player, SoundEnum.Click, function, slot, gui);
}
private static void command(Function slot, Player player) {
@ -112,7 +110,7 @@ public class GUIListener implements Listener {
@Override
public void run() {
if (slot.command_BungeeCommand) {
if (SelectConfig.Bungee) {
if (SelectConfig.getBungee()) {
for (String cmd : slot.command) {
Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.commandAsConsole);
}
@ -146,11 +144,11 @@ public class GUIListener implements Listener {
for (String msg : slot.message) {
if (Main.PaPi) {
if (slot.cost_Enable) {
send.player(player, Replace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.Currency));
send.player(player, Replace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.getCurrency()));
} else send.player(player, Replace.replace(prefix, player, Placeholder.replace(msg, player)));
} else {
if (slot.cost_Enable) {
send.player(player, Replace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.Currency));
send.player(player, Replace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.getCurrency()));
} else send.player(player, Replace.replace(prefix, Placeholder.replace(msg, player)));
}
}
@ -238,23 +236,9 @@ public class GUIListener 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) {
try {
player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.guiName) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.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 function, Gui gui, Player player) {
if (player.hasPermission(function.togglePermissionPerm)) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.getTogglePermFalse().replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() {
@Override
public void run() {
@ -263,7 +247,7 @@ public class GUIListener implements Listener {
}
}.runTaskLater(plugin, 4L);
} else
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.getTogglePermTrue().replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() {
@Override
public void run() {
@ -332,8 +316,7 @@ public class GUIListener implements Listener {
}
}.runTaskLater(plugin, 1L);
send.player(player, SelectMessages.noMoneyItem.replace("[item]", item[0]).replace("[amount]", item[1]));
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
Sound.play(player,SoundEnum.NoMoney);
} else {
send.player(player, SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
.replace("[price]", item[1] + " " + item[0]));
@ -349,8 +332,7 @@ public class GUIListener implements Listener {
}
}.runTaskLater(plugin, 1L);
send.player(player, SelectMessages.noMoneyVote.replace("[amount]", function.votePoints.toString()));
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
Sound.play(player,SoundEnum.NoMoney);
} else {
send.player(player, SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
.replace("[price]", function.votePoints + " VotePoints"));
@ -367,11 +349,10 @@ public class GUIListener implements Listener {
}
}.runTaskLater(plugin, 1L);
send.player(player, Replace.replacePrice(prefix, SelectMessages.noMoney, String.valueOf(function.price)));
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
Sound.play(player,SoundEnum.NoMoney);
} else {
send.player(player, SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
.replace("[price]", function.price + " " + SelectConfig.Currency));
.replace("[price]", function.price + " " + SelectConfig.getCurrency()));
execute(function, slot, player, e, gui);
}
break;

View File

@ -64,10 +64,10 @@ public class GuiBuilder {
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Function slot) {
if (Main.PaPi) {
itemMeta.setDisplayName(Replace.replace(prefix, player, Placeholder.replace(slot.name, player)));
itemMeta.setLore(Replace.replacePrice(prefix, player, Placeholder.replace(slot.lore, player), slot.price + " " + SelectConfig.Currency));
itemMeta.setLore(Replace.replacePrice(prefix, player, Placeholder.replace(slot.lore, player), slot.price + " " + SelectConfig.getCurrency()));
} else {
itemMeta.setDisplayName(Replace.replace(prefix, Placeholder.replace(slot.name,player)));
itemMeta.setLore(Replace.replacePrice(prefix, Placeholder.replace(slot.lore,player), slot.price + " " + SelectConfig.Currency));
itemMeta.setLore(Replace.replacePrice(prefix, Placeholder.replace(slot.lore,player), slot.price + " " + SelectConfig.getCurrency()));
}
}

View File

@ -1,13 +1,14 @@
package de.jatitv.commandguiv2.Spigot.gui;
import de.jatitv.commandguiv2.Spigot.listener.GUIListener;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.useItem.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import de.jatitv.commandguiv2.Spigot.sound.Sound;
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
import de.jatitv.commandguiv2.Util;
import io.github.solyze.plugmangui.inventories.PluginListGUI;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -127,9 +128,7 @@ public class OpenGUI {
}
if (sound) {
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
Sound.play(player, SoundEnum.OpenInventory);
}
player.openInventory(inventory);
send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
@ -137,14 +136,14 @@ public class OpenGUI {
}
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);
if (SelectConfig.getToggleItemOnOrYesBase64()) {
GuiBuilder.base64(SelectConfig.getToggleItemOnOrYesBase64Value(), function, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.getToggleItemOnOrYesMaterial(), 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);
if (SelectConfig.getToggleItemOffOrNoBase64()) {
GuiBuilder.base64(SelectConfig.getToggleItemOffOrNoBase64Value(), function, slot, player, inventory);
} else GuiBuilder.item(SelectConfig.getToggleItemOffOrNoMaterial(), function, slot, player, inventory);
}
}

View File

@ -1,4 +1,4 @@
package de.jatitv.commandguiv2.Spigot.system;
package de.jatitv.commandguiv2.Spigot.listener;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -64,4 +64,16 @@ public class Bungee_Sender_Reciver implements PluginMessageListener {
}
}
public static void send(Player player, String server){
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF(server);
} catch (IOException i) {
i.printStackTrace();
}
player.sendPluginMessage(Main.plugin, "BungeeCord", b.toByteArray());
}
}

View File

@ -3,18 +3,13 @@
package de.jatitv.commandguiv2.Spigot.listener;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class PluginEvent implements Listener {
private static String prefix = Util.getPrefix();
@ -25,55 +20,4 @@ public class PluginEvent implements Listener {
SelectDatabase.nameCheck(player);
UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
}
@EventHandler
public void onClearServer(ServerCommandEvent event) {
if (SelectConfig.UseItem_KeepAtCommandClear) {
if (event.getCommand().contains("clear " + event.getCommand().replace("/", "").replace("clear ", ""))) {
new BukkitRunnable() {
@Override
public void run() {
try {
Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", ""));
if (player == null){
return;
}
clearGive(player);
} catch (Exception ex){
ex.printStackTrace();
return;
}
}
}.runTaskLater(Main.plugin, 1L);
}
}
}
@EventHandler
public void onClearPlayer(PlayerCommandPreprocessEvent event) {
if (SelectConfig.UseItem_KeepAtCommandClear) {
if (event.getMessage().toLowerCase().contains("clear")) {
new BukkitRunnable() {
@Override
public void run() {
clearGive(event.getPlayer());
}
}.runTaskLater(Main.plugin, 1L);
}
if (event.getMessage().toLowerCase().contains("clear " + event.getMessage().toLowerCase().replace("/", "").replace("clear ", ""))) {
new BukkitRunnable() {
@Override
public void run() {
clearGive(Bukkit.getPlayer(event.getMessage().toLowerCase().replace("/", "").replace("clear ", "")));
}
}.runTaskLater(Main.plugin, 1L);
}
}
}
private static void clearGive(Player player) {
ItemChange.itemChange(player, false);
}
}

View File

@ -8,7 +8,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
public class ServerChange {
public static void send(Player player, String server){
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);

View File

@ -5,11 +5,9 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
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 de.jatitv.commandguiv2.Spigot.system.Debug;
import de.jatitv.commandguiv2.Spigot.system.EcoEnum;
import de.jatitv.commandguiv2.Spigot.system.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.system.FunctionVoteEnum;
import de.jatitv.commandguiv2.Util;
import de.jatitv.commandguiv2.Spigot.enums.EcoEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -1,8 +1,8 @@
package de.jatitv.commandguiv2.Spigot.objects.functions;
import de.jatitv.commandguiv2.Spigot.system.EcoEnum;
import de.jatitv.commandguiv2.Spigot.system.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.system.FunctionVoteEnum;
import de.jatitv.commandguiv2.Spigot.enums.EcoEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
import java.util.List;

View File

@ -0,0 +1,60 @@
package de.jatitv.commandguiv2.Spigot.sound;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
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 de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.entity.Player;
public class Sound {
private static String prefix = Util.getPrefix();
public static void play(Player player, SoundEnum soundEnum) {
if (!SelectConfig.getSound_Enable()) return;
play(player, soundEnum, null, null, null);
}
public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) {
if (!SelectConfig.getSound_Enable()) return;
switch (soundEnum) {
case OpenInventory:
if (!SelectConfig.getSound_OpenInventory_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_OpenInventory(), 3, 1);
break;
case Click:
if (!SelectConfig.getSound_Click_Enable()) return;
if (!function.customSound_Enable) player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
if (function.customSound_NoSound) return;
try {
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.guiName) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound));
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
}
break;
case NoMoney:
if (!SelectConfig.getSound_NoMoney_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoMoney(), 3, 1);
break;
case NoInventorySpace:
if (!SelectConfig.getSound_NoInventorySpace_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoInventorySpace(), 3, 1);
break;
case Give:
if (!SelectConfig.getSound_Give_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_Give(), 3, 1);
break;
case PlayerNotFound:
if (!SelectConfig.getSound_PlayerNotFound_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_PlayerNotFound(), 3, 1);
break;
}
}
}

View File

@ -1,7 +1,8 @@
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.listener.GUIListener;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.EventsFrom110;
import de.jatitv.commandguiv2.Spigot.gui.GUIListener;
import de.jatitv.commandguiv2.Spigot.listener.Bungee_Sender_Reciver;
import de.jatitv.commandguiv2.Spigot.useItem.EventsFrom110;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
@ -10,16 +11,16 @@ import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Spigot.database.MySQL;
import de.jatitv.commandguiv2.Spigot.listener.PluginEvent;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.useItem.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.SQLITE;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
import de.jatitv.commandguiv2.Spigot.database.SQLITE;
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.enums.StorageEnum;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@ -71,7 +72,7 @@ public class Load {
SelectConfig.setConfigVersion();
if (SelectConfig.Bungee) {
if (SelectConfig.getBungee()) {
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) {
send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "cgui:bungee");
@ -108,7 +109,7 @@ public class Load {
e.printStackTrace();
}
try {
CmdExecuter_GUI.arg1.put(SelectConfig.adminSubCommand, "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
CmdExecuter_GUI.arg1.put(SelectConfig.getAdminSubCommand(), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
} catch (Exception e) {
e.printStackTrace();
}
@ -129,7 +130,7 @@ public class Load {
e.printStackTrace();
}
if (SelectConfig.HelpAlias) {
if (SelectConfig.getHelpAlias()) {
Main.plugin.getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
send.debug(plugin, "CommandRegister: commandguihelp");
}
@ -161,11 +162,11 @@ public class Load {
private static void loadStorage(String prefix) {
try {
SelectDatabase.setStorage(StorageType.valueOf(SelectConfig.storage));
SelectDatabase.setStorage(StorageEnum.valueOf(SelectConfig.getStorage()));
} catch (Exception ignored) {
send.error(Main.plugin, "The storage medium " + SelectConfig.storage + " is not supported!");
send.error(Main.plugin, "Storage medium " + StorageType.SQLITE + " is used.");
SelectDatabase.setStorage(StorageType.SQLITE);
send.error(Main.plugin, "The storage medium " + SelectConfig.getStorage() + " is not supported!");
send.error(Main.plugin, "Storage medium " + StorageEnum.SQLITE + " is used.");
SelectDatabase.setStorage(StorageEnum.SQLITE);
}
switch (SelectDatabase.getStorage()) {

View File

@ -4,9 +4,7 @@
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
import de.jatitv.commandguiv2.Util;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -1,6 +1,6 @@
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.useItem.Events;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import org.bukkit.entity.Player;
@ -10,8 +10,8 @@ import java.util.List;
public class Placeholder {
public static String useitem(Player p) {
if (Events.useItemHashMap.get(p.getName())) {
return SelectConfig.placeholderTrue;
} else return SelectConfig.placeholderFalse;
return SelectConfig.getPlaceholderTrue();
} else return SelectConfig.getPlaceholderFalse();
}
public static String useitem_boolean(Player p) {

View File

@ -1,7 +0,0 @@
package de.jatitv.commandguiv2.Spigot.system.database;
public enum StorageType {
MYSQL,
SQLITE,
YML
}

View File

@ -1,16 +1,15 @@
package de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener;
package de.jatitv.commandguiv2.Spigot.useItem;
import de.jatitv.commandguiv2.Spigot.listener.ItemChange;
import de.jatitv.commandguiv2.Spigot.Main;
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.UseItem;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
import de.jatitv.commandguiv2.api.CGuiAPI;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -23,6 +22,7 @@ import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
@ -40,7 +40,7 @@ public class Events implements Listener {
useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer()));
Integer i = SelectDatabase.selectSlot(e.getPlayer());
if (i == null) {
useItemSlotHashMap.put(e.getPlayer().getName(), SelectConfig.UseItem_InventorySlot);
useItemSlotHashMap.put(e.getPlayer().getName(), SelectConfig.getUseItem_InventorySlot());
} else useItemSlotHashMap.put(e.getPlayer().getName(), i);
if (CGuiAPI.JoinDisable) {
@ -63,6 +63,8 @@ public class Events implements Listener {
useItemHashMap.remove(e.getPlayer().getName());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onDeathDrop(PlayerDeathEvent e) {
Player player = e.getEntity().getPlayer();
@ -72,7 +74,7 @@ public class Events implements Listener {
while (var3.hasNext()) {
ItemStack items = (ItemStack) var3.next();
if (items != null && items.hasItemMeta() && items.getItemMeta().hasDisplayName()
&& items.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& items.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.getDrops().remove(items);
}
}
@ -82,10 +84,10 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onRespawn(PlayerRespawnEvent e) {
Player player = e.getPlayer();
if (SelectConfig.UseItem_Enable) {
if (SelectConfig.getUseItem_Enable()) {
ItemChange.itemChange(player, false);
//if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
// if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
//if (!SelectConfig.getUseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
// if (SelectConfig.getUseItem_GiveOnlyOnFirstJoin) {
// if (!player.hasPlayedBefore()) {
// new BukkitRunnable() {
// @Override
@ -109,7 +111,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onGameModeChange(PlayerGameModeChangeEvent e) {
Player player = e.getPlayer();
if (!SelectConfig.UseItemGameModeChangeEnable) {
if (!SelectConfig.getUseItemGameModeChangeEnable()) {
return;
}
new BukkitRunnable() {
@ -117,13 +119,13 @@ public class Events implements Listener {
public void run() {
ItemChange.itemChange(player, false);
}
}.runTaskLater(Main.plugin, SelectConfig.UseItemGameModeChangeDelayInTicks * 1L);
}.runTaskLater(Main.plugin, SelectConfig.getUseItemGameModeChangeDelayInTicks() * 1L);
}
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent e) {
Player player = e.getPlayer();
if (!SelectConfig.UseItemWorldChangeEnable) {
if (!SelectConfig.getUseItemWorldChangeEnable()) {
return;
}
new BukkitRunnable() {
@ -131,30 +133,30 @@ public class Events implements Listener {
public void run() {
ItemChange.itemChange(player, false);
}
}.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L);
}.runTaskLater(Main.plugin, SelectConfig.getUseItemWorldChangeDelayInTicks() * 1L);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (!p.isSneaking()) {
for (String material : SelectConfig.UseItemItemBlockBlacklist) {
for (String material : SelectConfig.getUseItemItemBlockBlacklist()) {
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType() == Material.valueOf(material)) return;
}
}
}
if (SelectConfig.UseItem_Enable) {
if (SelectConfig.UseItem_PlayerHead_Enable) {
if (SelectConfig.getUseItem_Enable()) {
if (SelectConfig.getUseItem_PlayerHead_Enable()) {
if (e.getItem() != null && p.getItemInHand().getType() == ItemVersion.getHead()) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
openGUI(e, p);
}
}
} else {
if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(SelectConfig.UseItem_Material)) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(SelectConfig.getUseItem_Material())) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
openGUI(e, p);
}
}
@ -165,7 +167,7 @@ public class Events implements Listener {
private static void openGUI(PlayerInteractEvent e, Player player) {
e.setCancelled(true);
if ((!SelectConfig.disableInfoBySneak) && player.isSneaking()) {
if ((!SelectConfig.getDisableInfoBySneak()) && player.isSneaking()) {
Commands.info(player);
return;
}
@ -176,45 +178,45 @@ public class Events implements Listener {
if (UseItem.protection(player, true)) return;
if (SelectConfig.UseItemGameModeProtection) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
if (SelectConfig.getUseItemGameModeProtection()) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
e.setCancelled(true);
send.player(player, SelectMessages.UseItemDisabledInGameMode);
return;
}
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
e.setCancelled(true);
send.player(player, SelectMessages.UseItemDisabledInGameMode);
return;
}
}
if (SelectConfig.UseItemWorldProtection) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
if (SelectConfig.getUseItemWorldProtection()) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
e.setCancelled(true);
send.player(player, SelectMessages.UseItemDisabledInWorld);
return;
}
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
e.setCancelled(true);
send.player(player, SelectMessages.UseItemDisabledInWorld);
return;
}
}
if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true);
if (!SelectConfig.getUseItem_Permission() || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.getUseItem_OpenGUI(), true);
} else {
send.player(player,SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
.replace("[gui]", SelectConfig.UseItem_OpenGUI));
.replace("[gui]", SelectConfig.getUseItem_OpenGUI()));
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMoveEvent(InventoryMoveItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName()
&& e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
}
@ -222,19 +224,19 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryDragEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getWhoClicked() instanceof Player) {
Player p = (Player) e.getWhoClicked();
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
p.closeInventory();
e.setCancelled(true);
ItemChange.itemChange(p, false);
}
if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName()
&& e.getOldCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getOldCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
p.closeInventory();
e.setCancelled(true);
ItemChange.itemChange(p, false);
@ -244,14 +246,14 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemMove(InventoryClickEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
if (e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName()
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
@ -259,12 +261,12 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryPickupItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getItem() != null && e.getItem().getItemStack() != null) {
ItemStack item = e.getItem().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
}
@ -272,22 +274,21 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onDrop(PlayerDropItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
ItemStack item = e.getItemDrop().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
}
@ -296,4 +297,54 @@ public class Events implements Listener {
private static boolean topInventoryIsEmpty(Player p) {
return p.getOpenInventory().getTopInventory().isEmpty();
}
@EventHandler
public void onClearServer(ServerCommandEvent event) {
if (SelectConfig.getUseItem_KeepAtCommandClear()) {
if (event.getCommand().contains("clear " + event.getCommand().replace("/", "").replace("clear ", ""))) {
new BukkitRunnable() {
@Override
public void run() {
try {
Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", ""));
if (player == null){
return;
}
clearGive(player);
} catch (Exception ex){
ex.printStackTrace();
return;
}
}
}.runTaskLater(Main.plugin, 1L);
}
}
}
@EventHandler
public void onClearPlayer(PlayerCommandPreprocessEvent event) {
if (SelectConfig.getUseItem_KeepAtCommandClear()) {
if (event.getMessage().toLowerCase().contains("clear")) {
new BukkitRunnable() {
@Override
public void run() {
clearGive(event.getPlayer());
}
}.runTaskLater(Main.plugin, 1L);
}
if (event.getMessage().toLowerCase().contains("clear " + event.getMessage().toLowerCase().replace("/", "").replace("clear ", ""))) {
new BukkitRunnable() {
@Override
public void run() {
clearGive(Bukkit.getPlayer(event.getMessage().toLowerCase().replace("/", "").replace("clear ", "")));
}
}.runTaskLater(Main.plugin, 1L);
}
}
}
private static void clearGive(Player player) {
ItemChange.itemChange(player, false);
}
}

View File

@ -1,4 +1,4 @@
package de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener;
package de.jatitv.commandguiv2.Spigot.useItem;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@ -12,29 +12,27 @@ public class EventsFrom110 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onHandSwap(PlayerSwapHandItemsEvent e) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9) return;
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName()
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
}
if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName()
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(PlayerSwapHandItemsEvent e) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9) return;
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
Player p = e.getPlayer();
if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName()
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
p.closeInventory();
e.setCancelled(true);
}
if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName()
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
p.closeInventory();
e.setCancelled(true);
}

View File

@ -1,8 +1,6 @@
package de.jatitv.commandguiv2.Spigot.listener;
package de.jatitv.commandguiv2.Spigot.useItem;
import de.jatitv.commandguiv2.Spigot.listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.UseItem;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.entity.Player;
@ -11,19 +9,19 @@ import org.bukkit.scheduler.BukkitRunnable;
public class ItemChange {
public static void itemChange(Player player, Boolean setCursor) {
Integer slot;
if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot;
if (SelectConfig.getUseItem_InventorySlotEnforce()) {
slot = SelectConfig.getUseItem_InventorySlot();
} else {
slot = Events.useItemSlotHashMap.get(player.getName());
}
if (!SelectConfig.UseItem_Enable) {
if (!SelectConfig.getUseItem_Enable()) {
return;
}
UseItem.removeItem(player);
if (UseItem.protection(player, false)) return;
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player.getName())) {
if (SelectConfig.getUseItem_GiveOnlyOnFirstJoin()) {
if (!SelectConfig.getUseItem_AllowToggle() || Events.useItemHashMap.get(player.getName())) {
if (!player.hasPlayedBefore()) {
new BukkitRunnable() {
@Override
@ -34,7 +32,7 @@ public class ItemChange {
}
}
}.runTaskLater(Main.plugin, 1L * 1);
if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin || SelectConfig.Cursor_ToGUIItem_OnLogin) {
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin() || SelectConfig.getCursor_ToGUIItem_OnLogin()) {
player.getInventory().setHeldItemSlot(slot - 1);
}
}
@ -42,21 +40,23 @@ public class ItemChange {
send.debug(Main.plugin, "GiveOnlyOnFirstJoin: " + player.getName());
return;
}
if (!SelectConfig.UseItem_GiveOnEveryJoin) {
if (!SelectConfig.getUseItem_GiveOnEveryJoin()) {
send.debug(Main.plugin, "!GiveOnEveryJoin: " + player.getName());
return;
}
new BukkitRunnable() {
@Override
public void run() {
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player.getName())) {
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
Boolean pln = Events.useItemHashMap.get(player.getName());
if (pln == null) return;
if (!SelectConfig.getUseItem_AllowToggle() || pln) {
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(slot - 1) == null) {
send.debug(Main.plugin, "Give: " + player.getName());
UseItem.giveUseItem(player);
if (setCursor) {
setCursor(player, slot);
}
} else if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
} else if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) {
boolean empty = false;
for (int i = 0; i < 9; i++) {
if (player.getInventory().getItem(i) == null) {
@ -77,11 +77,11 @@ public class ItemChange {
private static void setCursor(Player player, int slot) {
send.debug(Main.plugin, "setCursor 1 Player: " + player.getName());
if (!SelectConfig.Cursor_ToGUIItem_OnLogin) {
if (!SelectConfig.getCursor_ToGUIItem_OnLogin()) {
return;
}
send.debug(Main.plugin, "setCursor 2 Player: " + player.getName());
if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) {
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin()) {
if (!player.hasPlayedBefore()) {
player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin, "setCursor 3 Player: " + player.getName());
@ -89,13 +89,13 @@ public class ItemChange {
return;
}
send.debug(Main.plugin, "setCursor 4 Player: " + player.getName());
if (!SelectConfig.Bungee) {
if (!SelectConfig.getBungee()) {
player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin, "setCursor 5 Player: " + player.getName());
return;
}
send.debug(Main.plugin, "setCursor 6 Player: " + player.getName());
if (SelectConfig.UseItem_ServerChange) {
if (SelectConfig.getUseItem_ServerChange()) {
player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin, "setCursor 7 Player: " + player.getName());
return;

View File

@ -1,8 +1,8 @@
package de.jatitv.commandguiv2.Spigot.system;
package de.jatitv.commandguiv2.Spigot.useItem;
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.useItem.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
@ -21,17 +21,15 @@ import java.lang.reflect.Field;
import java.util.UUID;
public class UseItem {
public static void giveUseItem(Player player) {
Integer slot;
if (protection(player, false)) return;
if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot;
if (SelectConfig.getUseItem_InventorySlotEnforce()) {
slot = SelectConfig.getUseItem_InventorySlot();
} else {
slot = Events.useItemSlotHashMap.get(player.getName());
}
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) {
player.getInventory().addItem(itemStack(player));
} else {
send.debug(Main.plugin, "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1)));
@ -41,27 +39,27 @@ public class UseItem {
public static void addUseItem(Player player) {
if (protection(player, false)) return;
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) {
player.getInventory().addItem(itemStack(player));
} else player.getInventory().addItem(itemStack(player));
}
private static ItemStack itemStack(Player player) {
ItemStack item = null;
if (SelectConfig.UseItem_PlayerHead_Enable) {
if (SelectConfig.getUseItem_PlayerHead_Enable()) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
send.player(player, Util.getPrefix() + "§c Playerheads for UseItem are only available from version §61.13§c!");
send.error(Main.plugin, "Playerheads for UseItem are only available from version 1.13!");
} else {
item = ItemVersion.getHeadIS();
SkullMeta playerheadmeta = (SkullMeta) item.getItemMeta();
playerheadmeta.setDisplayName(SelectConfig.UseItem_Name);
if (SelectConfig.UseItem_Base64_Enable) {
playerheadmeta.setDisplayName(SelectConfig.getUseItem_Name());
if (SelectConfig.getUseItem_Base64_Enable()) {
if (Main.PaPi) {
playerheadmeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.UseItem_Lore));
} else playerheadmeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.UseItem_Lore));
playerheadmeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore()));
} else playerheadmeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore()));
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", SelectConfig.UseItem_Base64value));
profile.getProperties().put("textures", new Property("textures", SelectConfig.getUseItem_Base64value()));
Field profileField = null;
try {
profileField = playerheadmeta.getClass().getDeclaredField("profile");
@ -72,23 +70,23 @@ public class UseItem {
}
} else {
String p;
if (SelectConfig.UseItem_PlayerWhoHasOpenedTheGUI) {
if (SelectConfig.getUseItem_PlayerWhoHasOpenedTheGUI()) {
p = player.getName();
} else p = SelectConfig.UseItem_PlayerName;
} else p = SelectConfig.getUseItem_PlayerName();
playerheadmeta.setOwner(p);
if (Main.PaPi) {
playerheadmeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.UseItem_Lore));
} else playerheadmeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.UseItem_Lore));
playerheadmeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore()));
} else playerheadmeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore()));
}
item.setItemMeta(playerheadmeta);
}
} else {
item = new ItemStack(Material.valueOf(SelectConfig.UseItem_Material));
item = new ItemStack(Material.valueOf(SelectConfig.getUseItem_Material()));
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(SelectConfig.UseItem_Name);
itemMeta.setDisplayName(SelectConfig.getUseItem_Name());
if (Main.PaPi) {
itemMeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.UseItem_Lore));
} else itemMeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.UseItem_Lore));
itemMeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore()));
} else itemMeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore()));
item.setItemMeta(itemMeta);
item.setAmount(1);
}
@ -96,31 +94,31 @@ public class UseItem {
}
public static boolean protection(Player player, Boolean interact) {
if (SelectConfig.UseItemGameModeProtection) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
if (SelectConfig.getUseItemGameModeProtection()) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
if (interact) {
send.player(player, SelectMessages.UseItemDisabledInGameMode);
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
} else if (!SelectConfig.getUseItemGameModeRemoveItemWhenItIsDisabled()) removeItem(player);
return true;
}
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
if (interact) {
send.player(player, SelectMessages.UseItemDisabledInGameMode);
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
} else if (!SelectConfig.getUseItemGameModeRemoveItemWhenItIsDisabled()) removeItem(player);
return true;
}
}
if (SelectConfig.UseItemWorldProtection) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
if (SelectConfig.getUseItemWorldProtection()) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
if (interact) {
send.player(player, SelectMessages.UseItemDisabledInWorld);
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
} else if (!SelectConfig.getUseItemWorldRemoveItemWhenItIsDisabled()) removeItem(player);
return true;
}
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
if (interact) {
send.player(player, SelectMessages.UseItemDisabledInWorld);
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
} else if (!SelectConfig.getUseItemWorldRemoveItemWhenItIsDisabled()) removeItem(player);
return true;
}
}
@ -132,8 +130,8 @@ public class UseItem {
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
if (itm.getType() == Material.valueOf(SelectConfig.getUseItem_Material()) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
player.getInventory().remove(itm);
player.updateInventory();
break;

View File

@ -1,13 +1,14 @@
package de.jatitv.commandguiv2;
import net.t2code.lib.Spigot.system.T2CodeMain;
public class Util {
private static Integer configVersion = 5;
private static double requiredT2CodeLibVersion = 12.0;
private static double requiredT2CodeLibVersion = 12.1;
private static String Prefix = "§8[§4C§9GUI§8]";
private static Integer SpigotID = 90671;
private static Integer BstatsID = 10840;
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
private static String Discord = "http://dc.t2code.net";
public static double getRequiredT2CodeLibVersion() {
return requiredT2CodeLibVersion;
@ -30,7 +31,7 @@ public class Util {
}
public static String getDiscord() {
return Discord;
return T2CodeMain.getDiscord();
}
public static Integer getConfigVersion() {

View File

@ -1,7 +1,7 @@
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.useItem.ItemChange;
import de.jatitv.commandguiv2.Spigot.useItem.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Help;
@ -9,7 +9,7 @@ import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.command.CommandSender;
@ -26,13 +26,13 @@ public class CGuiAPI {
public static boolean hasUseItemInMainHand(Player player) {
ItemStack item = player.getInventory().getItemInMainHand();
return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name);
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name());
}
public static boolean hasUseItemInOffHand(Player player) {
ItemStack item = player.getInventory().getItemInOffHand();
return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name);
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name());
}
public static void onItemChange(Player player, Boolean setCursor) {

View File

@ -15,4 +15,4 @@ commands:
description: CommandGUI Help
aliases: [cguihelp, guihelp]
commandgui-item:
aliases: [gui-item]
aliases: [gui-item, useitem]