9 Commits
2.7.1 ... 2.7.6

Author SHA1 Message Date
JaTiTV
5674b54593 Merge pull request '2.7.5' (#10) from 2.7.5 into main
Reviewed-on: JaTiTV/CommandGUI#10
2022-06-01 00:15:35 +02:00
381afeba89 2.7.5
Added the option for hover & clickable messages for players.
2022-06-01 00:01:15 +02:00
19822f7024 2.7.4 | MySQL Bugfix
MySQL Bugfix
```
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`' at line 1
```
And minor code changes
2022-05-28 21:46:04 +02:00
ed810f31d7 Update pom.xml 2022-05-17 21:25:53 +02:00
b0286e597f Merge branch 'main' of https://git.t2code.net/JaTiTV/CommandGUI 2022-05-17 21:04:30 +02:00
ddfea4eba6 2.7.3
CHANGE: The placeholders are now usable internally in the plugin, even if PlaceholderAPI is not available.

FIX: Playerheads, Base64 Heads are now also available with 1.8 - 1.12
2022-05-17 21:04:23 +02:00
JaTiTV
ed86e7b143 „README.md“ ändern 2022-05-17 00:56:19 +02:00
32c1219bb2 2.7.2
ADD: Added a UseItem Item/Block Blacklist so that when you look at one of these blocks, the GUI does not open but the block (for example: CHEST, CRAFTING_TABLE, or buttons).
2022-05-17 00:19:39 +02:00
326dfae0e9 2.7.2
Small code changes that fixes minor bugs
2022-05-16 14:03:53 +02:00
33 changed files with 626 additions and 441 deletions

View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId> <artifactId>CommandGUI_V2</artifactId>
<version>2.7.1</version> <version>2.7.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandGUI</name> <name>CommandGUI</name>
@@ -85,7 +85,7 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>11.6</version> <version>11.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>

View File

@@ -1,5 +1,7 @@
package de.jatitv.commandguiv2.Bungee; package de.jatitv.commandguiv2.Bungee;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Util;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -33,6 +35,7 @@ public class BListener implements Listener {
} }
} }
} catch (IOException e) { } catch (IOException e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@@ -27,6 +27,9 @@ import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Util;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.ConfigurationProvider;
@@ -291,6 +294,7 @@ public class BMetrics {
// Send the data // Send the data
sendData(data); sendData(data);
} catch (Exception e) { } catch (Exception e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
// Something went wrong! :( // Something went wrong! :(
if (logErrors) { if (logErrors) {
errorLogger.accept("Could not submit bStats metrics data", e); errorLogger.accept("Could not submit bStats metrics data", e);

View File

@@ -10,6 +10,8 @@ import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.Papi;
import de.jatitv.commandguiv2.Spigot.system.Placeholder;
import de.jatitv.commandguiv2.Util; import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
@@ -48,42 +50,46 @@ public class GUIListener implements Listener {
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.guiName)))) { || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.guiName)))) {
e.setCancelled(true); e.setCancelled(true);
for (Slot slot : gui.slots) { for (Slot slot : gui.slots) {
Function function = Main.functionHashMap.get(slot.function); execute(e, slot, player, gui);
if (e.getSlot() != slot.slot) continue; }
if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue; }
if (slot.permission && !player.hasPermission(slot.permissionToUse)) { }
player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name)) }
.replace("[perm]", slot.permissionToUse));
continue;
}
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() ||
e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() ||
e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) {
if (!slot.enable) continue;
if (function.cost_Enable) {
if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) {
if (!Vault.buy(prefix, player, function.price)) { private static void execute(InventoryClickEvent e, Slot slot, Player player, Gui gui) {
new BukkitRunnable() { Function function = Main.functionHashMap.get(slot.function);
@Override if (e.getSlot() != slot.slot) return;
public void run() { if (slot.permission && !player.hasPermission(slot.permissionToSee)) return;
player.closeInventory(); if (slot.permission && !player.hasPermission(slot.permissionToUse)) {
} send.player(player,SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name))
}.runTaskLater(plugin, 1L); .replace("[perm]", slot.permissionToUse));
player.sendMessage(SelectMessages.No_money); return;
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) }
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1); if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() ||
} else { e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() ||
player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name)) e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) {
.replace("[price]", function.price + " " + SelectConfig.Currency)); if (!slot.enable) return;
execute(function, slot, player, e, gui); if (function.cost_Enable) {
} if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) {
if (!Vault.buy(prefix, player, function.price)) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
} }
} else { }.runTaskLater(plugin, 1L);
execute(function, slot, player, e, gui); send.player(player,SelectMessages.No_money);
} if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
} else {
send.player(player,SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
.replace("[price]", function.price + " " + SelectConfig.Currency));
execute(function, slot, player, e, gui);
} }
} }
} else {
execute(function, slot, player, e, gui);
} }
} }
} }
@@ -149,12 +155,12 @@ public class GUIListener implements Listener {
for (String msg : slot.message) { for (String msg : slot.message) {
if (Main.PaPi) { if (Main.PaPi) {
if (slot.cost_Enable) { if (slot.cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.price + " " + SelectConfig.Currency)); send.player(player, Replace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.Currency));
} else player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix))); } else send.player(player, Replace.replace(prefix, player, Placeholder.replace(msg, player)));
} else { } else {
if (slot.cost_Enable) { if (slot.cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, msg, slot.price + " " + SelectConfig.Currency)); send.player(player, Replace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.Currency));
} else player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix))); } else send.player(player, Replace.replace(prefix, Placeholder.replace(msg, player)));
} }
} }
} }
@@ -191,7 +197,7 @@ public class GUIListener implements Listener {
} else if (slot.configOptionPremat.equals("List")) { } else if (slot.configOptionPremat.equals("List")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueLeft); yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueLeft);
} else { } else {
player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo send.player(player,"§cCheck the Option §6SetConfig/Option/Premat"); //todo
} }
} }
if (e.getClick() == ClickType.RIGHT) { if (e.getClick() == ClickType.RIGHT) {
@@ -206,7 +212,7 @@ public class GUIListener implements Listener {
} else if (slot.configOptionPremat.equals("List")) { } else if (slot.configOptionPremat.equals("List")) {
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueRight); yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueRight);
} else { } else {
player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo send.player(player,"§cCheck the Option §6SetConfig/Option/Premat"); //todo
} }
} }
try { try {
@@ -261,7 +267,7 @@ public class GUIListener implements Listener {
} }
private static void toggleUseItem(Player player, Gui gui) { private static void toggleUseItem(Player player, Gui gui) {
if (Events.useItemHashMap.get(player)) { if (Events.useItemHashMap.get(player.getName())) {
Commands.itemOff(player); Commands.itemOff(player);
} else { } else {
Commands.itemOn(player); Commands.itemOn(player);

View File

@@ -4,6 +4,7 @@ import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.UseItem; import de.jatitv.commandguiv2.Spigot.system.UseItem;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@@ -14,11 +15,7 @@ public class ItemChange {
if (SelectConfig.UseItem_InventorySlotEnforce) { if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot; slot = SelectConfig.UseItem_InventorySlot;
} else { } else {
if (Events.useItemSlotHashMap.get(player) == null) { slot = Events.useItemSlotHashMap.get(player.getName());
slot = SelectConfig.UseItem_InventorySlot;
} else {
slot = Events.useItemSlotHashMap.get(player);
}
} }
if (!SelectConfig.UseItem_Enable) { if (!SelectConfig.UseItem_Enable) {
@@ -27,7 +24,7 @@ public class ItemChange {
UseItem.removeItem(player); UseItem.removeItem(player);
if (UseItem.protection(player, false)) return; if (UseItem.protection(player, false)) return;
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) { if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) { if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player.getName())) {
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@@ -53,8 +50,7 @@ public class ItemChange {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (player == null) return; if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player.getName())) {
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) { if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
send.debug(Main.plugin, "Give: " + player.getName()); send.debug(Main.plugin, "Give: " + player.getName());
UseItem.giveUseItem(player); UseItem.giveUseItem(player);

View File

@@ -34,16 +34,16 @@ import java.util.Iterator;
public class Events implements Listener { public class Events implements Listener {
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>(); public static HashMap<String, Boolean> useItemHashMap = new HashMap<>();
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>(); public static HashMap<String, Integer> useItemSlotHashMap = new HashMap<>();
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
if (SelectDatabase.selectItemStatus(e.getPlayer())) { useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer()));
useItemHashMap.put(e.getPlayer(), true); Integer i = SelectDatabase.selectSlot(e.getPlayer());
} else useItemHashMap.put(e.getPlayer(), false); if (i == null) {
useItemSlotHashMap.put(e.getPlayer().getName(), SelectConfig.UseItem_InventorySlot);
useItemSlotHashMap.put(e.getPlayer(), SelectDatabase.selectSlot(e.getPlayer())); } else useItemSlotHashMap.put(e.getPlayer().getName(), i);
if (CGuiAPI.JoinDisable) { if (CGuiAPI.JoinDisable) {
send.debug(Main.plugin, "JoinDisable"); send.debug(Main.plugin, "JoinDisable");
@@ -62,7 +62,7 @@ public class Events implements Listener {
@EventHandler @EventHandler
public void onJoin(PlayerQuitEvent e) { public void onJoin(PlayerQuitEvent e) {
useItemHashMap.remove(e.getPlayer()); useItemHashMap.remove(e.getPlayer().getName());
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@@ -136,10 +136,17 @@ public class Events implements Listener {
}.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L); }.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L);
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!p.isSneaking()) {
for (String material : SelectConfig.UseItemItemBlockBlacklist) {
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType() == Material.valueOf(material)) return;
}
}
}
if (SelectConfig.UseItem_Enable) { if (SelectConfig.UseItem_Enable) {
if (SelectConfig.UseItem_PlayerHead_Enable) { if (SelectConfig.UseItem_PlayerHead_Enable) {
if (e.getItem() != null && p.getItemInHand().getType() == ItemVersion.getHead()) { if (e.getItem() != null && p.getItemInHand().getType() == ItemVersion.getHead()) {
@@ -165,7 +172,7 @@ public class Events implements Listener {
return; return;
} }
if (!legacy()) { if (!Main.legacy) {
if (!topInventoryIsEmpty(player)) return; if (!topInventoryIsEmpty(player)) return;
} }
@@ -200,7 +207,7 @@ public class Events implements Listener {
if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) { if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true); OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true);
} else { } else {
player.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") send.player(player,SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
.replace("[gui]", SelectConfig.UseItem_OpenGUI)); .replace("[gui]", SelectConfig.UseItem_OpenGUI));
} }
} }
@@ -288,12 +295,6 @@ public class Events implements Listener {
} }
} }
private static boolean legacy() {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) {
return true;
} else return false;
}
private static boolean topInventoryIsEmpty(Player p) { private static boolean topInventoryIsEmpty(Player p) {
return p.getOpenInventory().getTopInventory().isEmpty(); return p.getOpenInventory().getTopInventory().isEmpty();
} }

View File

@@ -8,6 +8,8 @@ import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Util; import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@@ -27,6 +29,7 @@ public final class Main extends JavaPlugin {
} }
private static Boolean enable = false; private static Boolean enable = false;
public static Boolean legacy = false;
public static String prefix = "§8[§4C§9GUI§8]"; public static String prefix = "§8[§4C§9GUI§8]";
@@ -57,7 +60,10 @@ public final class Main extends JavaPlugin {
plugin = this; plugin = this;
autor = plugin.getDescription().getAuthors(); autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion(); version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) {
legacy = true;
}
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
if (PluginCheck.papi()) { if (PluginCheck.papi()) {
PaPi = true; PaPi = true;

View File

@@ -1,7 +1,6 @@
package de.jatitv.commandguiv2.Spigot.cmdManagement; package de.jatitv.commandguiv2.Spigot.cmdManagement;
import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.Debug;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI; import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Util; import de.jatitv.commandguiv2.Util;
@@ -17,7 +16,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter { public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
@Override @Override
@@ -61,24 +60,6 @@ public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter {
} else sender.sendMessage(SelectMessages.NoPermissionForCommand } else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
break; break;
case "debug":
if (sender.hasPermission("commandgui.admin")) {
Debug.onDebugFile(sender);
/*if (args.length == 2) {
if (args[1].equals("config")) {
Debug.debugmsg();
}
if (args[1].equals("2")) {
send.debug("2");
}
break;
} else Debug.debugmsg();
*/
} else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
break;
case "give": case "give":
if (args.length == 3) { if (args.length == 3) {
if (sender.hasPermission("commandgui.giveitem.other")) { if (sender.hasPermission("commandgui.giveitem.other")) {

View File

@@ -23,7 +23,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
if (sender.hasPermission("commandgui.useitem.toggle")) { if (sender.hasPermission("commandgui.useitem.toggle")) {
if (args.length == 0) { if (args.length == 0) {
if (SelectConfig.UseItem_AllowToggle) { if (SelectConfig.UseItem_AllowToggle) {
Help.sendGUIItemHelp(sender, prefix); Help.sendGUIItemHelp(sender);
} else send.sender(sender, "§4UseItem toggle is disabled!");// todo } else send.sender(sender, "§4UseItem toggle is disabled!");// todo
} else { } else {
if (args.length == 1 || args.length == 2) { if (args.length == 1 || args.length == 2) {

View File

@@ -7,21 +7,17 @@ import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister; import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.UseItem; import de.jatitv.commandguiv2.Spigot.system.UseItem;
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate; import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.Permissions; import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Util; import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Objects; import java.util.Objects;
@@ -63,14 +59,14 @@ public class Commands {
send.console(Util.getPrefix() + " §6Plugin reload..."); send.console(Util.getPrefix() + " §6Plugin reload...");
send.console(Util.getPrefix() + "§8-------------------------------"); send.console(Util.getPrefix() + "§8-------------------------------");
CmdExecuter_GUITab.arg1.clear(); CmdExecuter_GUI.arg1.clear();
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
SelectConfig.onSelect(); SelectConfig.onSelect();
Main.plugin.reloadConfig(); Main.plugin.reloadConfig();
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) { if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) {
if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!"); if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!");
send.console("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!");
} }
LanguagesCreate.langCreate(); LanguagesCreate.langCreate();
@@ -124,11 +120,7 @@ public class Commands {
if (SelectConfig.UseItem_InventorySlotEnforce) { if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot; slot = SelectConfig.UseItem_InventorySlot;
} else { } else {
if (Events.useItemSlotHashMap.get(player) == null) { slot = Events.useItemSlotHashMap.get(player.getName());
slot = SelectConfig.UseItem_InventorySlot;
} else {
slot = Events.useItemSlotHashMap.get(player);
}
} }
send.debug(Main.plugin, String.valueOf(slot)); send.debug(Main.plugin, String.valueOf(slot));
if (player.getInventory().getItem(slot - 1) == null) { if (player.getInventory().getItem(slot - 1) == null) {
@@ -147,7 +139,7 @@ public class Commands {
UseItem.addUseItem(player); UseItem.addUseItem(player);
send.player(player, SelectMessages.ItemON); send.player(player, SelectMessages.ItemON);
} else { } else {
player.sendMessage(SelectMessages.NoInventorySpace); send.player(player,SelectMessages.NoInventorySpace);
if (SelectConfig.Sound_NoInventorySpace_Enable && SelectConfig.Sound_Enable) { if (SelectConfig.Sound_NoInventorySpace_Enable && SelectConfig.Sound_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_NoInventorySpace, 3, 1); player.playSound(player.getLocation(), SelectConfig.Sound_NoInventorySpace, 3, 1);
} }
@@ -162,7 +154,7 @@ public class Commands {
public static void onSetSlot(Player player, Integer setSlot) { public static void onSetSlot(Player player, Integer setSlot) {
if (!SelectConfig.UseItem_AllowSetSlot) { if (!SelectConfig.UseItem_AllowSetSlot) {
player.sendMessage(Util.getPrefix() + " §4Function disabled"); send.player(player,Util.getPrefix() + " §4Function disabled");
return; return;
} }
@@ -175,9 +167,9 @@ public class Commands {
return; return;
} }
if (Events.useItemHashMap.get(player)) { if (Events.useItemHashMap.get(player.getName())) {
if (Objects.equals(Events.useItemSlotHashMap.get(player), setSlot)) { if (Objects.equals(Events.useItemSlotHashMap.get(player.getName()), setSlot)) {
player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString())); send.player(player,SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
return; return;
} }
} }
@@ -189,9 +181,9 @@ public class Commands {
UseItem.removeItem(player); UseItem.removeItem(player);
SelectDatabase.setSlot(player, setSlot); SelectDatabase.setSlot(player, setSlot);
Events.useItemSlotHashMap.replace(player, setSlot); Events.useItemSlotHashMap.replace(player.getName(), setSlot);
if (Events.useItemHashMap.get(player)) { if (Events.useItemHashMap.get(player.getName())) {
UseItem.giveUseItem(player); UseItem.giveUseItem(player);
} }
@@ -204,9 +196,9 @@ public class Commands {
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || 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.DefaultGUI, true);
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui") } else send.player(player,SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
.replace("[perm]", "commandgui.command")); .replace("[perm]", "commandgui.command"));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName)); } else send.player(player,SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
} }
} }
@@ -216,9 +208,9 @@ public class Commands {
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, arg, true); OpenGUI.openGUI(player, arg, true);
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key) } else send.player(player,SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key)
.replace("[perm]", "commandgui.command." + arg.toLowerCase())); .replace("[perm]", "commandgui.command." + arg.toLowerCase()));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.key)); } else send.player(player,SelectMessages.GUIIsDisabled.replace("[gui]", gui.key));
} else player.sendMessage(SelectMessages.GUInotFound); } else send.player(player,SelectMessages.GUInotFound);
} }
} }

View File

@@ -8,43 +8,104 @@ import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.replace.Replace; import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Help { public class Help {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
public static void sendHelp(CommandSender sender, String Prefix) { public static void sendHelp(CommandSender sender, String Prefix) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----"); send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
if (sender.hasPermission("commandgui.command")) { cgui(sender, gui);
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); open(sender);
send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.guiName))); help(sender);
for (String alias : Main.allAliases) { gUIItemHelp(sender);
if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) { info(sender);
send.sender(sender, Prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix,Main.guiHashMap.get(alias).guiName))); give(sender);
} createDefaultGUI(sender);
} reload(sender);
send.sender(sender, Prefix + " " + SelectMessages.HelpHelp);
}
if (sender.hasPermission("commandgui.useitem.toggle")) {
send.sender(sender, Prefix + " " + SelectMessages.GUIItemHelp_on);
send.sender(sender, Prefix + " " + SelectMessages.GUIItemHelp_off);
send.sender(sender, Prefix + " " + SelectMessages.GUIItemHelp_Slot);
}
if (sender.hasPermission("commandgui.command.info")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpInfo);
}
if (sender.hasPermission("commandgui.admin")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath()+ "\\GUIs\\default.yml"));
send.sender(sender, Prefix + " " + SelectMessages.HelpReload);
}
send.sender(sender, Prefix + " §8-------------------------"); send.sender(sender, Prefix + " §8-------------------------");
} }
public static void sendGUIItemHelp(CommandSender sender, String Prefix) {
private static void cgui(CommandSender sender, Gui gui) {
if (!sender.hasPermission("commandgui.command")) return;
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpCgui.replace("[gui]", Replace.replace(prefix, gui.guiName)));
} else send.sender(sender, prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix, gui.guiName)));
}
private static void open(CommandSender sender) {
if (!sender.hasPermission("commandgui.command")) return;
for (String alias : Main.allAliases) {
if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) {
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix, Main.guiHashMap.get(alias).guiName)));
} else
send.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix, Main.guiHashMap.get(alias).guiName)));
}
}
}
private static void help(CommandSender sender) {
if (!sender.hasPermission("commandgui.command")) return;
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpHelp);
} else send.sender(sender, prefix + " " + SelectMessages.HelpHelp);
}
private static void info(CommandSender sender) {
if (!sender.hasPermission("commandgui.command.info")) return;
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpInfo);
} else send.sender(sender, prefix + " " + SelectMessages.HelpInfo);
}
private static void give(CommandSender sender) {
if (!sender.hasPermission("commandgui.admin")) return;
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpGive);
} else send.sender(sender, prefix + " " + SelectMessages.HelpGive);
}
private static void createDefaultGUI(CommandSender sender) {
if (!sender.hasPermission("commandgui.admin")) return;
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpCreateDefaultGUI.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
} else send.sender(sender, prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
}
private static void reload(CommandSender sender) {
if (!sender.hasPermission("commandgui.admin")) return;
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpReload);
} else send.sender(sender, prefix + " " + SelectMessages.HelpReload);
}
public static void gUIItemHelp(CommandSender sender) {
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_on);
} else send.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_on);
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_off);
} else send.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_off);
if (sender instanceof Player) {
send.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_Slot);
} else send.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_Slot);
}
public static void sendGUIItemHelp(CommandSender sender) {
if (sender.hasPermission("commandgui.useitem.toggle")) { if (sender.hasPermission("commandgui.useitem.toggle")) {
send.sender(sender, Prefix + " §8------ §4Command§9GUI§2Item §chelp §8------"); send.sender(sender, prefix + " §8------ §4Command§9GUI§2Item §chelp §8------");
send.sender(sender, Prefix + " " + SelectMessages.GUIItemHelp_on); gUIItemHelp(sender);
send.sender(sender, Prefix + " " + SelectMessages.GUIItemHelp_off); send.sender(sender, prefix + " §8------------------------------");
send.sender(sender, Prefix + " " + SelectMessages.GUIItemHelp_Slot);
send.sender(sender, Prefix + " §8------------------------------");
} }
} }
} }

View File

@@ -5,6 +5,7 @@ import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -26,9 +27,9 @@ public class RegisterCommand extends Command {
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, alias, true); OpenGUI.openGUI(player, alias, true);
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias) } else send.player(player,SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias)
.replace("[perm]", "commandgui.command." + alias)); .replace("[perm]", "commandgui.command." + alias));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName)); } else send.player(player,SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
} else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!"); } else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!");
return true; return true;
} }

View File

@@ -6,15 +6,19 @@ import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
public class ConfigCreate { public class ConfigCreate {
public static void configCreate() { public static void configCreate() {
long long_ = System.currentTimeMillis(); long long_ = System.currentTimeMillis();
if (new File(Main.getPath(), "config.yml").exists()) { if (new File(Main.getPath(), "config.yml").exists()) {
@@ -32,7 +36,9 @@ public class ConfigCreate {
Config.set("Plugin.Currency", "$", yamlConfiguration); Config.set("Plugin.Currency", "$", yamlConfiguration);
Config.set("Plugin.DefaultGUI", "default", yamlConfiguration); Config.set("Plugin.DefaultGUI", "default", yamlConfiguration);
Config.set("Storage.Type", "SQLITE", yamlConfiguration); if (Main.legacy){
Config.set("Storage.Type", "YML", yamlConfiguration);
} else Config.set("Storage.Type", "SQLITE", yamlConfiguration);
Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration); Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration);
Config.set("Storage.MySQL.Port", 3306, yamlConfiguration); Config.set("Storage.MySQL.Port", 3306, yamlConfiguration);
Config.set("Storage.MySQL.Database", "database", yamlConfiguration); Config.set("Storage.MySQL.Database", "database", yamlConfiguration);
@@ -99,14 +105,45 @@ public class ConfigCreate {
Config.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", 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.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), 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.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration); Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration); if (Main.legacy) {
Config.set("Toggle.Items.OnOrYes.Item.Material", "WOOL,5", yamlConfiguration);
} else Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration); Config.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration); Config.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Material", ItemVersion.getRedWool().getType().toString(), yamlConfiguration); if (Main.legacy) {
Config.set("Toggle.Items.OffOrNo.Item.Material", "WOOL,14", yamlConfiguration);
} else Config.set("Toggle.Items.OffOrNo.Item.Material", ItemVersion.getRedWool().getType().toString(), yamlConfiguration);
Config.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration); Config.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration);
Config.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration); Config.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration);

View File

@@ -4,8 +4,6 @@ import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL; import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
import de.jatitv.commandguiv2.Util; import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@@ -57,6 +55,7 @@ public class SelectConfig {
public static Boolean UseItemWorldRemoveItemWhenItIsDisabled; public static Boolean UseItemWorldRemoveItemWhenItIsDisabled;
public static String UseItemWorldMode; public static String UseItemWorldMode;
public static List<String> UseItemWorldList; public static List<String> UseItemWorldList;
public static List<String> UseItemItemBlockBlacklist;
public static Boolean disableInfoBySneak = false; public static Boolean disableInfoBySneak = false;
@@ -189,10 +188,13 @@ public class SelectConfig {
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode"); UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List"); UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) { if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) {
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak"); disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
} }
UseItemItemBlockBlacklist = yamlConfiguration.getStringList("Advanced.UseItem.ItemBlockBlacklist");
toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable"); toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable");
toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value"); toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value");
toggleItemOnOrYesMaterial = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Material"); toggleItemOnOrYesMaterial = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Material");

View File

@@ -21,7 +21,7 @@ public class CreateFunctions {
0, 0.0, Arrays.asList(), false, ""); 0, 0.0, Arrays.asList(), false, "");
createFunction("SupportDiscord", false, 1, true, true, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19", createFunction("SupportDiscord", false, 1, true, true, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19",
false, "", (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) ? "TNT" : "", false, "", "",
"&3Support Discord", Arrays.asList("&8-----------------", "&bIf you need help setting up the plugin,", "&bfeel free to contact me on the Suport Discord.", "&3Support Discord", Arrays.asList("&8-----------------", "&bIf you need help setting up the plugin,", "&bfeel free to contact me on the Suport Discord.",
"&8-----------------", "&eIf you find any errors or bugs,", "&eplease contact me so I can fix them.", "&8-----------------", "&5Discord: §7http://dc.t2code.net"), "&8-----------------", "&eIf you find any errors or bugs,", "&eplease contact me so I can fix them.", "&8-----------------", "&5Discord: §7http://dc.t2code.net"),
false, false, "", false, 0.0, false, false, false, false, "", false, 0.0, false, false,

View File

@@ -71,6 +71,17 @@ public class LanguagesCreate {
set("Help.UseItem_Off", MSG.EN_GUIItemHelp_off, yamlConfigurationEN); set("Help.UseItem_Off", MSG.EN_GUIItemHelp_off, yamlConfigurationEN);
set("Help.UseItem_Slot", MSG.EN_GUIItemHelp_Slot, yamlConfigurationEN); set("Help.UseItem_Slot", MSG.EN_GUIItemHelp_Slot, yamlConfigurationEN);
set("Help.Player.CGUI", MSG.EN_PlayerHelp_CGUI, yamlConfigurationEN);
set("Help.Player.Help", MSG.EN_PlayerHelp_Help, yamlConfigurationEN);
set("Help.Player.Info", MSG.EN_PlayerHelp_Info, yamlConfigurationEN);
set("Help.Player.Open", MSG.EN_PlayerHelp_Open, yamlConfigurationEN);
set("Help.Player.Give", MSG.EN_PlayerHelp_Give, yamlConfigurationEN);
set("Help.Player.CreateDefaultGUI", MSG.EN_PlayerHelp_CreateDefaultGUI, yamlConfigurationEN);
set("Help.Player.Reload", MSG.EN_PlayerHelp_Reload, yamlConfigurationEN);
set("Help.Player.UseItem_On", MSG.EN_GUIItemPlayerHelp_on, yamlConfigurationEN);
set("Help.Player.UseItem_Off", MSG.EN_GUIItemPlayerHelp_off, yamlConfigurationEN);
set("Help.Player.UseItem_Slot", MSG.EN_GUIItemPlayerHelp_Slot, yamlConfigurationEN);
try { try {
yamlConfigurationEN.save(messagesEN); yamlConfigurationEN.save(messagesEN);
} catch (IOException e) { } catch (IOException e) {
@@ -135,6 +146,17 @@ public class LanguagesCreate {
set("Help.UseItem_Off", MSG.DE_GUIItemHelp_off, yamlConfigurationDE); set("Help.UseItem_Off", MSG.DE_GUIItemHelp_off, yamlConfigurationDE);
set("Help.UseItem_Slot", MSG.DE_GUIItemHelp_Slot, yamlConfigurationDE); set("Help.UseItem_Slot", MSG.DE_GUIItemHelp_Slot, yamlConfigurationDE);
set("Help.Player.CGUI", MSG.DE_PlayerHelp_CGUI, yamlConfigurationDE);
set("Help.Player.Help", MSG.DE_PlayerHelp_Help, yamlConfigurationDE);
set("Help.Player.Info", MSG.DE_PlayerHelp_Info, yamlConfigurationDE);
set("Help.Player.Open", MSG.DE_PlayerHelp_Open, yamlConfigurationDE);
set("Help.Player.Give", MSG.DE_PlayerHelp_Give, yamlConfigurationDE);
set("Help.Player.CreateDefaultGUI", MSG.DE_PlayerHelp_CreateDefaultGUI, yamlConfigurationDE);
set("Help.Player.Reload", MSG.DE_PlayerHelp_Reload, yamlConfigurationDE);
set("Help.Player.UseItem_On", MSG.DE_GUIItemPlayerHelp_on, yamlConfigurationDE);
set("Help.Player.UseItem_Off", MSG.DE_GUIItemPlayerHelp_off, yamlConfigurationDE);
set("Help.Player.UseItem_Slot", MSG.DE_GUIItemPlayerHelp_Slot, yamlConfigurationDE);
try { try {
yamlConfigurationDE.save(messagesDE); yamlConfigurationDE.save(messagesDE);
} catch (IOException e) { } catch (IOException e) {
@@ -200,6 +222,17 @@ public class LanguagesCreate {
set("Help.UseItem_Off", MSG.NO_GUIItemHelp_off, yamlConfigurationNO); set("Help.UseItem_Off", MSG.NO_GUIItemHelp_off, yamlConfigurationNO);
set("Help.UseItem_Slot", MSG.NO_GUIItemHelp_Slot, yamlConfigurationNO); set("Help.UseItem_Slot", MSG.NO_GUIItemHelp_Slot, yamlConfigurationNO);
set("Help.Player.CGUI", MSG.NO_PlayerHelp_CGUI, yamlConfigurationNO);
set("Help.Player.Help", MSG.NO_PlayerHelp_Help, yamlConfigurationNO);
set("Help.Player.Info", MSG.NO_PlayerHelp_Info, yamlConfigurationNO);
set("Help.Player.Open", MSG.NO_PlayerHelp_Open, yamlConfigurationNO);
set("Help.Player.Give", MSG.NO_PlayerHelp_Give, yamlConfigurationNO);
set("Help.Player.CreateDefaultGUI", MSG.NO_PlayerHelp_CreateDefaultGUI, yamlConfigurationNO);
set("Help.Player.Reload", MSG.NO_PlayerHelp_Reload, yamlConfigurationNO);
set("Help.Player.UseItem_On", MSG.NO_GUIItemPlayerHelp_on, yamlConfigurationNO);
set("Help.Player.UseItem_Off", MSG.NO_GUIItemPlayerHelp_off, yamlConfigurationNO);
set("Help.Player.UseItem_Slot", MSG.NO_GUIItemPlayerHelp_Slot, yamlConfigurationNO);
try { try {
yamlConfigurationNO.save(messagesNO); yamlConfigurationNO.save(messagesNO);
} catch (IOException e) { } catch (IOException e) {

View File

@@ -60,7 +60,18 @@ public class MSG {
public static String EN_GUIItemHelp_on = "&8''&b/gui-item on&8'' &eActivate the GUIItem for you."; public static String EN_GUIItemHelp_on = "&8''&b/gui-item on&8'' &eActivate the GUIItem for you.";
public static String EN_GUIItemHelp_off = "&8''&b/gui-item off&8'' &eDisable the GUIItem for yourself."; public static String EN_GUIItemHelp_off = "&8''&b/gui-item off&8'' &eDisable the GUIItem for yourself.";
public static String EN_GUIItemHelp_Slot = "&8''&b/gui-item slot [slot]&8'' &eSet the slot for GUIItem for you."; public static String EN_GUIItemHelp_Slot = "&8''&b/gui-item slot &7<slot>&8'' &eSet the slot where you want to have the GUIItem.";
public static String EN_PlayerHelp_CGUI = "&b/commandgui &8| &b/cgui/*/&eOpen the default GUI &7(&r[gui]&7)&e./*/SUGGEST_COMMAND/*//commandgui";
public static String EN_PlayerHelp_Open = "&b/commandgui [gui]/*/&eOpen the GUI: &6[guiname]&e./*/SUGGEST_COMMAND/*//commandgui ";
public static String EN_PlayerHelp_Help = "&b/commandguihelp/*/&eOpen this help./*/SUGGEST_COMMAND/*//commandguihelp";
public static String EN_PlayerHelp_Info = "&b/commandgui admin info/*/&eCall the info from &4Command&9GUI &e./*/SUGGEST_COMMAND/*//commandgui admin info";
public static String EN_PlayerHelp_Give = "&b/commandgui admin give &7<player>/*/&eGive a player the GUI item./*/SUGGEST_COMMAND/*//commandgui admin give ";
public static String EN_PlayerHelp_CreateDefaultGUI = "&b/commandgui admin createdefaultgui/*/&eCreate a default GUI &7([directory])&e./*/SUGGEST_COMMAND/*//commandgui admin createdefaultgui";
public static String EN_PlayerHelp_Reload = "&b/commandgui admin reload/*/&eReload the plugin./*/SUGGEST_COMMAND/*//commandgui admin reload";
public static String EN_GUIItemPlayerHelp_on = "&b/gui-item on/*/&eActivate the GUIItem for you./*/SUGGEST_COMMAND/*//gui-item on";
public static String EN_GUIItemPlayerHelp_off = "&b/gui-item off/*/&eDisable the GUIItem for yourself./*/SUGGEST_COMMAND/*//gui-item off";
public static String EN_GUIItemPlayerHelp_Slot = "&b/gui-item slot &7<slot>/*/&eSet the slot where you want to have the GUIItem./*/SUGGEST_COMMAND/*//gui-item slot ";
// DE // DE
public static String DE_VaultNotSetUp = "[prefix] &4Vault / Economy nicht eingerichtet!"; public static String DE_VaultNotSetUp = "[prefix] &4Vault / Economy nicht eingerichtet!";
@@ -109,7 +120,19 @@ public class MSG {
public static String DE_GUIItemHelp_on = "&8''&b/gui-item on&8'' &eAktiviere f[ue]r dich das GUIItem."; public static String DE_GUIItemHelp_on = "&8''&b/gui-item on&8'' &eAktiviere f[ue]r dich das GUIItem.";
public static String DE_GUIItemHelp_off = "&8''&b/gui-item off&8'' &eDeaktiviere f[ue]r dich das GUIItem."; public static String DE_GUIItemHelp_off = "&8''&b/gui-item off&8'' &eDeaktiviere f[ue]r dich das GUIItem.";
public static String DE_GUIItemHelp_Slot = "&8''&b/gui-item slot [slot]&8'' &eSetze den Slot für GUIItem für Sie einstellen."; public static String DE_GUIItemHelp_Slot = "&8''&b/gui-item slot &7<slot>&8'' &eStelle den Slot ein, auf den du das GUIItem haben möchtest.";
public static String DE_PlayerHelp_CGUI = "&b/commandgui &8| &b/cgui/*/&e[OE]ffne die default GUI &7(&r[gui]&7)&e./*/SUGGEST_COMMAND/*//commandgui";
public static String DE_PlayerHelp_Open = "&b/commandgui [gui]/*/&e[OE]ffne die GUI: &6[guiname]&e./*/SUGGEST_COMMAND/*//commandgui ";
public static String DE_PlayerHelp_Help = "&b/commandguihelp/*/&e[OE]ffne diese help./*/SUGGEST_COMMAND/*//commandguihelp";
public static String DE_PlayerHelp_Info = "&b/commandgui admin info/*/&eRufe die Infos von &4Command&9GUI &eauf./*/SUGGEST_COMMAND/*//commandgui admin info";
public static String DE_PlayerHelp_Give = "&b/commandgui admin give &7<player>/*/&eGebe einem Spieler das GUI-Item./*/SUGGEST_COMMAND/*//commandgui admin give ";
public static String DE_PlayerHelp_CreateDefaultGUI = "&b/commandgui admin createdefaultgui/*/&eLasse eine default GUI erstellen &7([directory])&e./*/SUGGEST_COMMAND/*//commandgui admin createdefaultgui";
public static String DE_PlayerHelp_Reload = "&b/commandgui admin reload/*/&eLade das Plugin neu./*/SUGGEST_COMMAND/*//commandgui admin reload";
public static String DE_GUIItemPlayerHelp_on = "&b/gui-item on/*/&eAktiviere f[ue]r dich das GUIItem./*/SUGGEST_COMMAND/*//gui-item on";
public static String DE_GUIItemPlayerHelp_off = "&b/gui-item off/*/&eDeaktiviere f[ue]r dich das GUIItem./*/SUGGEST_COMMAND/*//gui-item off";
public static String DE_GUIItemPlayerHelp_Slot = "&b/gui-item slot &7<slot>/*/&eStelle den Slot ein, auf den du das GUIItem haben möchtest./*/SUGGEST_COMMAND/*//gui-item slot ";
// FR // FR
@@ -162,5 +185,17 @@ public class MSG {
public static String NO_GUIItemHelp_on = "&8''&b/gui-item on&8'' &eAktiverer en GUI gjenstand for deg."; public static String NO_GUIItemHelp_on = "&8''&b/gui-item on&8'' &eAktiverer en GUI gjenstand for deg.";
public static String NO_GUIItemHelp_off = "&8''&b/gui-item off&8'' &eDeaktiverer en GUI gjenstand for deg."; public static String NO_GUIItemHelp_off = "&8''&b/gui-item off&8'' &eDeaktiverer en GUI gjenstand for deg.";
public static String NO_GUIItemHelp_Slot = "&8''&b/gui-item slot [slot]&8'' &eSett sporet for GUIItem for deg."; public static String NO_GUIItemHelp_Slot = "&8''&b/gui-item slot &7<slot>&8'' &eSett sporet for GUIItem for deg.";
public static String NO_PlayerHelp_CGUI = "&b/commandgui &8| &b/cgui/*/&eÅpne default GUIen &7(&r[gui]&7)&e./*/SUGGEST_COMMAND/*//commandgui";
public static String NO_PlayerHelp_Open = "&b/commandgui [gui]/*/&eÅpne GUIen: &6[guiname]&e./*/SUGGEST_COMMAND/*//commandgui ";
public static String NO_PlayerHelp_Help = "&b/commandguihelp/*/&eSender denne hjelpe meldingen./*/SUGGEST_COMMAND/*//commandguihelp";
public static String NO_PlayerHelp_Info = "&b/commandgui admin info/*/&eKall informasjon fra &4Command&9GUI&e./*/SUGGEST_COMMAND/*//commandgui admin info";
public static String NO_PlayerHelp_Give = "&b/commandgui admin give &7<player>/*/&eGi en spiller GUI gjenstanden./*/SUGGEST_COMMAND/*//commandgui admin give ";
public static String NO_PlayerHelp_CreateDefaultGUI = "&b/commandgui admin createdefaultgui/*/&eLag en normalverdi GUI &7([directory])&e./*/SUGGEST_COMMAND/*//commandgui admin createdefaultgui";
public static String NO_PlayerHelp_Reload = "&b/commandgui admin reload/*/&eLast inn pluginet på nytt./*/SUGGEST_COMMAND/*//commandgui admin reload";
public static String NO_GUIItemPlayerHelp_on = "&b/gui-item on/*/&eAktiverer en GUI gjenstand for deg./*/SUGGEST_COMMAND/*//gui-item on";
public static String NO_GUIItemPlayerHelp_off = "&b/gui-item off/*/&eDeaktiverer en GUI gjenstand for deg./*/SUGGEST_COMMAND/*//gui-item off";
public static String NO_GUIItemPlayerHelp_Slot = "&b/gui-item slot &7<slot>/*/&eSett sporet for GUIItem for deg./*/SUGGEST_COMMAND/*//gui-item slot ";
} }

View File

@@ -8,6 +8,7 @@ import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.util.Objects;
public class SelectMessages { public class SelectMessages {
@@ -60,11 +61,21 @@ public class SelectMessages {
public static String GUIItemHelp_on; public static String GUIItemHelp_on;
public static String GUIItemHelp_off; public static String GUIItemHelp_off;
public static String GUIItemHelp_Slot; public static String GUIItemHelp_Slot;
public static String PlayerHelpCgui;
public static String PlayerHelpHelp;
public static String PlayerHelpInfo;
public static String PlayerHelpOpen;
public static String PlayerHelpGive;
public static String PlayerHelpCreateDefaultGUI;
public static String PlayerHelpReload;
public static String PlayerGUIItemHelp_on;
public static String PlayerGUIItemHelp_off;
public static String PlayerGUIItemHelp_Slot;
public static void onSelect(String Prefix) { public static void onSelect(String Prefix) {
send.debug(Main.plugin, "§4Select language..."); send.debug(Main.plugin, "§4Select language...");
Long long_ = Long.valueOf(System.currentTimeMillis()); long long_ = System.currentTimeMillis();
File msg; File msg;
@@ -128,11 +139,22 @@ public class SelectMessages {
GUIItemHelp_off = select("Help.UseItem_Off", yamlConfiguration_msg); GUIItemHelp_off = select("Help.UseItem_Off", yamlConfiguration_msg);
GUIItemHelp_Slot = select("Help.UseItem_Slot", yamlConfiguration_msg); GUIItemHelp_Slot = select("Help.UseItem_Slot", yamlConfiguration_msg);
PlayerHelpCgui = select("Help.Player.CGUI", yamlConfiguration_msg);
PlayerHelpHelp = select("Help.Player.Help", yamlConfiguration_msg);
PlayerHelpInfo = select("Help.Player.Info", yamlConfiguration_msg);
PlayerHelpOpen = select("Help.Player.Open", yamlConfiguration_msg);
PlayerHelpGive = select("Help.Player.Give", yamlConfiguration_msg);
PlayerHelpCreateDefaultGUI = select("Help.Player.CreateDefaultGUI", yamlConfiguration_msg);
PlayerHelpReload = select("Help.Player.Reload", yamlConfiguration_msg);
PlayerGUIItemHelp_on = select("Help.Player.UseItem_On", yamlConfiguration_msg);
PlayerGUIItemHelp_off = select("Help.Player.UseItem_Off", yamlConfiguration_msg);
PlayerGUIItemHelp_Slot = select("Help.Player.UseItem_Slot", yamlConfiguration_msg);
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} }
private static String select(String path, YamlConfiguration yamlConfiguration){ private static String select(String path, YamlConfiguration yamlConfiguration){
return Replace.replace(Util.getPrefix(),yamlConfiguration.getString(path)); return Replace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(path)));
} }
} }

View File

@@ -6,6 +6,8 @@ import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.Papi;
import de.jatitv.commandguiv2.Spigot.system.Placeholder;
import de.jatitv.commandguiv2.Util; import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@@ -25,7 +27,11 @@ public class GuiBuilder {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
protected static void item(Function function, Integer slot, Player player, Inventory inventory) { protected static void item(Function function, Integer slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(function.item.toUpperCase().replace(".", "_"))); ItemStack item;
if (Main.legacy && function.item.toUpperCase().contains(",")) {
String[] split = function.item.toUpperCase().split(",");
item = new ItemStack(Material.valueOf(split[0]), 1, Short.parseShort(split[1]));
} else item = new ItemStack(Material.valueOf(function.item.toUpperCase().replace(".", "_")));
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, function); setDisplayNameAndLore(itemMeta, player, function);
item.setItemMeta(itemMeta); item.setItemMeta(itemMeta);
@@ -37,8 +43,12 @@ public class GuiBuilder {
inventory.setItem(slot, item); inventory.setItem(slot, item);
} }
protected static void item(String material, Function function,Integer slot, Player player, Inventory inventory) { protected static void item(String material, Function function, Integer slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(material)); ItemStack item;
if (Main.legacy && material.contains(",")) {
String[] split = material.split(",");
item = new ItemStack(Material.valueOf(split[0]), 1, Short.parseShort(split[1]));
} else item = new ItemStack(Material.valueOf(material));
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, function); setDisplayNameAndLore(itemMeta, player, function);
item.setItemMeta(itemMeta); item.setItemMeta(itemMeta);
@@ -53,11 +63,11 @@ public class GuiBuilder {
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Function slot) { private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Function slot) {
if (Main.PaPi) { if (Main.PaPi) {
itemMeta.setDisplayName(Replace.replace(prefix, player, slot.name.replace("[player]", player.getName()))); itemMeta.setDisplayName(Replace.replace(prefix, player, Placeholder.replace(slot.name, player)));
itemMeta.setLore(Replace.replacePrice(prefix, player, slot.lore, slot.price + " " + SelectConfig.Currency)); itemMeta.setLore(Replace.replacePrice(prefix, player, Placeholder.replace(slot.lore, player), slot.price + " " + SelectConfig.Currency));
} else { } else {
itemMeta.setDisplayName(Replace.replace(prefix, slot.name.replace("[player]", player.getName()))); itemMeta.setDisplayName(Replace.replace(prefix, Placeholder.replace(slot.name,player)));
itemMeta.setLore(Replace.replacePrice(prefix, slot.lore, slot.price + " " + SelectConfig.Currency)); itemMeta.setLore(Replace.replacePrice(prefix, Placeholder.replace(slot.lore,player), slot.price + " " + SelectConfig.Currency));
} }
} }
@@ -88,11 +98,11 @@ public class GuiBuilder {
} }
} }
protected static void base64(Function function,Integer slot, Player player, Inventory inventory) { protected static void base64(Function function, Integer slot, Player player, Inventory inventory) {
base64(function.base64Value, function,slot, player, inventory); base64(function.base64Value, function, slot, player, inventory);
} }
protected static void playerHead(Function function, Integer slot,Player player, Inventory inventory, String skullName) { protected static void playerHead(Function function, Integer slot, Player player, Inventory inventory, String skullName) {
ItemStack item = ItemVersion.getHeadIS(); ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, function); setDisplayNameAndLore(itemMeta, player, function);
@@ -109,7 +119,7 @@ public class GuiBuilder {
public static void fillItem(Inventory inventory, Gui gui) { public static void fillItem(Inventory inventory, Gui gui) {
ItemStack glass; ItemStack glass;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.guiFillItemItem)); glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.parseShort(gui.guiFillItemItem));
} else glass = new ItemStack(Material.valueOf(gui.guiFillItemItem.toUpperCase().replace(".", "_"))); } else glass = new ItemStack(Material.valueOf(gui.guiFillItemItem.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta(); ItemMeta itemMetaglass = glass.getItemMeta();
itemMetaglass.setDisplayName(" "); itemMetaglass.setDisplayName(" ");

View File

@@ -95,28 +95,20 @@ public class OpenGUI {
toggleOff(function, slot.slot, player, inventory); toggleOff(function, slot.slot, player, inventory);
} }
} else if (function.toggleUseItem) { } else if (function.toggleUseItem) {
if (Events.useItemHashMap.get(player)) { if (Events.useItemHashMap.get(player.getName())) {
toggleOn(function, slot.slot, player, inventory); toggleOn(function, slot.slot, player, inventory);
} else { } else {
toggleOff(function, slot.slot, player, inventory); toggleOff(function, slot.slot, player, inventory);
} }
} else { } else {
if (function.playerHead_Enable) { if (function.playerHead_Enable) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { if (function.base64_Enable) {
send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + GuiBuilder.base64(function, slot.slot, player, inventory);
Replace.replace(prefix, gui.guiName).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
send.error(plugin, "Playerheads are only available from version 1.13!");
send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.guiName).toString() + " §bSlot: §6" +
(slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
} else { } else {
if (function.base64_Enable) { if (function.playerWhoHasOpenedTheGUI) {
GuiBuilder.base64(function, slot.slot, player, inventory); GuiBuilder.playerHead(function, slot.slot, player, inventory, player.getName());
} else { } else {
if (function.playerWhoHasOpenedTheGUI) { GuiBuilder.playerHead(function, slot.slot, player, inventory, function.playerName);
GuiBuilder.playerHead(function, slot.slot, player, inventory, player.getName());
} else {
GuiBuilder.playerHead(function, slot.slot, player, inventory, function.playerName);
}
} }
} }
} else { } else {
@@ -134,7 +126,7 @@ public class OpenGUI {
} }
player.openInventory(inventory); player.openInventory(inventory);
send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.guiName))); } else send.player(player,SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.guiName)));
} }
private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) { private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) {

View File

@@ -1,10 +1,11 @@
package de.jatitv.commandguiv2.Spigot.objects; package de.jatitv.commandguiv2.Spigot.objects;
import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -13,7 +14,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class Obj_Select { public class Obj_Select {
public static void onSelect() { public static void onSelect() {
@@ -28,63 +28,66 @@ public class Obj_Select {
File[] fileArray = f.listFiles(); File[] fileArray = f.listFiles();
for (File config_gui : fileArray) { for (File config_gui : fileArray) {
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (sub.equals(".yml")) {
String key = config_gui.getName().replace(".yml", "");
Main.allAliases.add(key);
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui);
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable"); try {
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines"); String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) { if (sub.equals(".yml")) {
yamlConfiguration_gui.set("GUI.Lines", 6); String key = config_gui.getName().replace(".yml", "");
} Main.allAliases.add(key);
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) { YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui);
yamlConfiguration_gui.set("GUI.Lines", 1);
}
String guiName = yamlConfiguration_gui.getString("GUI.Name"); Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable"); Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
String guiFillItemItem; if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { yamlConfiguration_gui.set("GUI.Lines", 6);
guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor"); }
} else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item"); if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
yamlConfiguration_gui.set("GUI.Lines", 1);
Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
ArrayList<Slot> slots = new ArrayList<>();
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
Function functionCheck = Main.functionHashMap.get(function);
if (functionCheck == null) {
send.error(Main.plugin, "The Function " + function + " in the GUI " + key + " does not exist!");
} }
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required");
String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See");
String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use");
Slot slot = new Slot(slotNumber, enable, function, permRequired, String guiName = yamlConfiguration_gui.getString("GUI.Name");
Objects.requireNonNull(permSee).replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1)) Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
.replace("[slotname]", slotKey.toLowerCase()), String guiFillItemItem;
Objects.requireNonNull(permUse).replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1)) if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
.replace("[slotname]", slotKey.toLowerCase())); guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor");
slots.add(slot); } else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item");
}
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
key, commandAliasEnable, commandPermission, slots); Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
ArrayList<Slot> slots = new ArrayList<>();
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
Function functionCheck = Main.functionHashMap.get(function);
if (functionCheck == null) {
send.error(Main.plugin, "The Function " + function + " in the GUI " + key + " does not exist!");
}
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required");
String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See");
String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use");
Slot slot = new Slot(slotNumber, enable, function, permRequired,
permSee.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
.replace("[slotname]", slotKey.toLowerCase()),
permUse.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
.replace("[slotname]", slotKey.toLowerCase()));
slots.add(slot);
}
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
key, commandAliasEnable, commandPermission, slots);
Main.guiHashMap.put(key, gui);
CmdExecuter_GUI.arg1.put(config_gui.getName()
.replace(".yml", ""), "commandgui.gui." + key);
Main.guiHashMap.put(key, gui);
CmdExecuter_GUITab.arg1.put(config_gui.getName()
.replace(".yml", ""), "commandgui.gui." + key);
try {
yamlConfiguration_gui.save(config_gui); yamlConfiguration_gui.save(config_gui);
} catch (IOException e) {
e.printStackTrace();
} }
} catch (Exception e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace();
} }
} }
} }

View File

@@ -15,18 +15,17 @@ import java.util.List;
public class Debug { public class Debug {
private static Plugin plugin = Main.plugin; private static final Plugin plugin = Main.plugin;
public static void debugmsg() { public static void debugmsg() {
send.debug(plugin, "§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.debug(plugin, "§3Bukkit Version: §e" + Bukkit.getBukkitVersion());
send.debug(plugin,"§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); send.debug(plugin, "§3NMS Version: §e" + Bukkit.getServer().getClass().getPackage().getName().replace("org.bukkit.craftbukkit.", ""));
send.debug(plugin,"§3Bukkit Version: §e" + Bukkit.getBukkitVersion()); send.debug(plugin, "§3Version: §e" + Bukkit.getVersion());
send.debug(plugin,"§3NMS Version: §e" + Bukkit.getServer().getClass().getPackage().getName().replace("org.bukkit.craftbukkit.", "")); send.debug(plugin, "§3Java: §e" + System.getProperty("java.version"));
send.debug(plugin,"§3Version: §e" + Bukkit.getVersion()); send.debug(plugin, "§3Worlds: §e" + String.valueOf(Bukkit.getServer().getWorlds()));
send.debug(plugin,"§3Java: §e" + System.getProperty("java.version")); send.debug(plugin, String.valueOf(Main.plugins));
send.debug(plugin,"§3Worlds: §e" +String.valueOf(Bukkit.getServer().getWorlds())); send.debug(plugin, "§5----------------------------------");
send.debug(plugin,String.valueOf(Main.plugins));
send.debug(plugin,"§5----------------------------------");
if (new File(Main.getPath(), "config.yml").exists()) { if (new File(Main.getPath(), "config.yml").exists()) {
File f = new File(String.valueOf(Main.getPath())); File f = new File(String.valueOf(Main.getPath()));
File f2 = new File(String.valueOf(Main.getPath() + "/GUIs/")); File f2 = new File(String.valueOf(Main.getPath() + "/GUIs/"));
@@ -34,63 +33,24 @@ public class Debug {
File[] fileArray = f.listFiles(); File[] fileArray = f.listFiles();
File[] fileArray2 = f2.listFiles(); File[] fileArray2 = f2.listFiles();
File[] fileArray3 = f3.listFiles(); File[] fileArray3 = f3.listFiles();
for (File config : fileArray) { if (fileArray != null) {
send.debug(plugin,String.valueOf(config).replace("plugins/CommandGUI/", "")); for (File config : fileArray) {
send.debug(plugin, String.valueOf(config).replace("plugins/CommandGUI/", ""));
}
} }
for (File config2 : fileArray2) { if (fileArray2 != null) {
send.debug(plugin,String.valueOf(config2).replace("plugins/CommandGUI/", "")); for (File config2 : fileArray2) {
} send.debug(plugin, String.valueOf(config2).replace("plugins/CommandGUI/", ""));
for (File config3 : fileArray3) { }
send.debug(plugin,String.valueOf(config3).replace("plugins/CommandGUI/", "")); } else send.debug(plugin, "No GUI files available");
}
}
send.debug(plugin,"§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
} if (fileArray3 != null) {
for (File config3 : fileArray3) {
send.debug(plugin, String.valueOf(config3).replace("plugins/CommandGUI/", ""));
}
} else send.debug(plugin, "No language files available");
public static void onDebugFile(CommandSender sender){
String timeStamp = new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss").format(Calendar.getInstance().getTime());
String timeStampcfg = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(Calendar.getInstance().getTime());
send.sender(sender, Main.prefix + " §5Debug file was createt: §e" + Main.getPath() + "\\debug\\commandgui_debug_"+ timeStamp +".yml");
File debug = new File(Main.getPath(), "debug/commandgui_debug_"+ timeStamp +".yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(debug);
set("Time", timeStampcfg, yamlConfiguration);
set("CommandGUI.Version", String.valueOf(plugin.getDescription().getVersion()), yamlConfiguration);
set("Server.Bukkit_Version", String.valueOf(Bukkit.getBukkitVersion()), yamlConfiguration);
set("Server.NMS_Version", String.valueOf(Bukkit.getServer().getClass().getPackage().getName().replace("org.bukkit.craftbukkit.", "")), yamlConfiguration);
set("Server.Version", String.valueOf(Bukkit.getVersion()), yamlConfiguration);
set("Server.Java", String.valueOf(System.getProperty("java.version")), yamlConfiguration);
set("Server.Worlds", String.valueOf(Bukkit.getServer().getWorlds()), yamlConfiguration);
set("Server.Plugins", String.valueOf(Main.plugins) , yamlConfiguration);
try {
yamlConfiguration.save(debug);
} catch (IOException e) {
send.warning(plugin,e.getMessage());
e.printStackTrace();
}
}
private static void set(String path, String value, YamlConfiguration config){
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Integer value, YamlConfiguration config){
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, Boolean value, YamlConfiguration config){
if (!config.contains(path)) {
config.set(path, value);
}
}
private static void set(String path, List value, YamlConfiguration config){
if (!config.contains(path)) {
config.set(path, value);
} }
send.debug(plugin, "§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
} }
} }

View File

@@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Listener.GUIListener; import de.jatitv.commandguiv2.Spigot.Listener.GUIListener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.EventsFrom110; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.EventsFrom110;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister; import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
@@ -20,6 +20,7 @@ import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.SQLITE; import de.jatitv.commandguiv2.Spigot.system.database.SQLITE;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.system.database.StorageType; import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@@ -35,7 +36,7 @@ import java.util.List;
public class Load { public class Load {
static Plugin plugin = Main.plugin; static Plugin plugin = Main.plugin;
public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) { public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord); Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
try { try {
@@ -83,7 +84,7 @@ public class Load {
} }
if (PluginCheck.papi()) { if (PluginCheck.papi()) {
new Placeholder().register(); new Papi().register();
} }
try { try {
@@ -97,7 +98,7 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -132,7 +133,7 @@ public class Load {
Main.plugin.getCommand("commandguihelp").setExecutor(new CmdExecuter_Help()); Main.plugin.getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
send.debug(plugin, "CommandRegister: commandguihelp"); send.debug(plugin, "CommandRegister: commandguihelp");
} }
Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUITab()); Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUI());
send.debug(plugin, "CommandRegister: commandgui"); send.debug(plugin, "CommandRegister: commandgui");
Main.plugin.getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem()); Main.plugin.getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem());
send.debug(plugin, "CommandRegister: commandgui-item"); send.debug(plugin, "CommandRegister: commandgui-item");
@@ -177,15 +178,19 @@ public class Load {
" `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," + " `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," +
" `Status` INT(1) NOT NULL DEFAULT '1'," + " `Status` INT(1) NOT NULL DEFAULT '1'," +
" `Slot` INT(1) NULL DEFAULT NULL," + " `Slot` INT(1) NULL DEFAULT NULL," +
" UNIQUE INDEX `UUID` (`UUID`)" + " UNIQUE INDEX `UUID` (`UUID`)" +
")" + ")" +
"COLLATE='utf8mb4_general_ci'" + "COLLATE='utf8mb4_general_ci'" +
"ENGINE=InnoDB" + "ENGINE=InnoDB" +
";"); ";");
MySQL.query("ALTER TABLE `gui-item` ADD COLUMN IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;");
} catch (Exception e) { } catch (Exception e) {
Util.sendTryCatch(Load.class, e.getStackTrace()[0]);
e.printStackTrace(); e.printStackTrace();
} }
try {
MySQL.query("ALTER TABLE `gui-item` ADD COLUMN `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;");
} catch (SQLException e) {
}
break; break;
case YML: case YML:
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used."); send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
@@ -194,17 +199,17 @@ public class Load {
case SQLITE: case SQLITE:
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used."); send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
try { try {
SQLITE.main(); SQLITE.main();
SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
"UUID TEXT NOT NULL," + "UUID TEXT NOT NULL," +
"Name TEXT NOT NULL," + "Name TEXT NOT NULL," +
"Status INTEGER NOT NULL DEFAULT 1," + "Status INTEGER NOT NULL DEFAULT 1," +
"Slot INTEGER," + "Slot INTEGER," +
"PRIMARY KEY(UUID)" + "PRIMARY KEY(UUID)" +
");"); ");");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
break; break;
} }
} }

View File

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

View File

@@ -1,56 +1,38 @@
// This claas was created by JaTiTV
package de.jatitv.commandguiv2.Spigot.system; package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Placeholder extends PlaceholderExpansion { import java.util.ArrayList;
import java.util.List;
@Override public class Placeholder {
public String getIdentifier() { public static String useitem(Player p) {
return "commandgui"; if (Events.useItemHashMap.get(p.getName())) {
return SelectConfig.placeholderTrue;
} else return SelectConfig.placeholderFalse;
} }
@Override public static String useitem_boolean(Player p) {
public String getAuthor() { return Events.useItemHashMap.get(p.getName()).toString();
return Main.plugin.getDescription().getAuthors().toString();
} }
@Override public static String slot(Player p) {
public String getVersion() { return Events.useItemSlotHashMap.get(p.getName()).toString();
return Main.plugin.getDescription().getVersion();
} }
@Override public static String replace(String input, Player player) {
public boolean canRegister() { return input.replace("[player]", player.getName()).replace("%commandgui_useitem%", useitem(player))
return true; .replace("%commandgui_useitem_boolean%", useitem_boolean(player)).replace("%commandgui_useitem_slot%", slot(player));
} }
public static List<String> replace(List<String> input, Player player) {
ArrayList<String> rp = new ArrayList<String>();
@Override for (String s : input) {
public boolean persist() { rp.add(s.replace("[player]", player.getName()).replace("%commandgui_useitem%", useitem(player))
return true; .replace("%commandgui_useitem_boolean%", useitem_boolean(player)).replace("%commandgui_useitem_slot%", slot(player)));
}
@Override
public String onPlaceholderRequest(Player p, String params) {
if (params.contains("useitem_boolean")) {
return Events.useItemHashMap.get(p).toString();
} }
return rp;
if (params.contains("useitem")) {
if (Events.useItemHashMap.get(p)) {
return SelectConfig.placeholderTrue;
} else return SelectConfig.placeholderFalse;
}
if (params.contains("slot")){
return Events.useItemSlotHashMap.get(p).toString();
}
return null;
} }
} }

View File

@@ -29,11 +29,7 @@ public class UseItem {
if (SelectConfig.UseItem_InventorySlotEnforce) { if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot; slot = SelectConfig.UseItem_InventorySlot;
} else { } else {
if (Events.useItemSlotHashMap.get(player) == null) { slot = Events.useItemSlotHashMap.get(player.getName());
slot = SelectConfig.UseItem_InventorySlot;
} else {
slot = Events.useItemSlotHashMap.get(player);
}
} }
if (SelectConfig.UseItem_InventorySlot_FreeSlot) { if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
player.getInventory().addItem(itemStack(player)); player.getInventory().addItem(itemStack(player));

View File

@@ -3,7 +3,9 @@ package de.jatitv.commandguiv2.Spigot.system.database;
import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.Bukkit;
import java.sql.*; import java.sql.*;
import java.time.ZoneId; import java.time.ZoneId;
@@ -40,37 +42,48 @@ public class MySQL {
send.console(Main.prefix + " §4MYSQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); send.console(Main.prefix + " §4MYSQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
send.error(Main.plugin, ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms"); 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")) {
try {
send.error(Main.plugin, "MySQL DEBUG:");
Connection con = ds.getConnection();
DatabaseMetaData dbmd = con.getMetaData();
send.debugmsg(Main.plugin, "§6Metadata of the database:");
send.debugmsg(Main.plugin, "§6DB: §e" + dbmd.getDatabaseProductName());
send.debugmsg(Main.plugin, "§6Version: §e" + dbmd.getDatabaseProductVersion());
send.debugmsg(Main.plugin, "§6Driver: §e" + dbmd.getDriverName());
send.debugmsg(Main.plugin, "§6Driver MajorVersion: §e" + dbmd.getDriverMajorVersion() + "." + dbmd.getDriverMinorVersion());
send.debugmsg(Main.plugin, "§6Driver Version: §e" + dbmd.getDriverVersion());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
//Bukkit.getConsoleSender().sendMessage((System.currentTimeMillis() - long_) + "ms"); //Bukkit.getConsoleSender().sendMessage((System.currentTimeMillis() - long_) + "ms");
} }
public static void query(String query) { public static void query(String query) throws SQLException {
if (ds == null) {
if (ds == null){
return; return;
} }
send.debug(Main.plugin, query); send.debug(Main.plugin, query);
try (Connection con = ds.getConnection()) { Connection con = ds.getConnection();
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
stmt.execute(query); stmt.execute(query);
stmt.close(); stmt.close();
} catch (SQLException e) {
System.err.println(e.getMessage());
}
} }
public static void query(ArrayList<String> queryList) { public static void query(ArrayList<String> queryList) throws SQLException {
try (Connection con = ds.getConnection()) { Connection con = ds.getConnection();
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
for (String query : queryList) { for (String query : queryList) {
send.debug(Main.plugin, query); send.debug(Main.plugin, query);
stmt.addBatch(query); stmt.addBatch(query);
}
stmt.executeBatch();
stmt.close();
} catch (SQLException e) {
System.err.println(e.getMessage());
} }
stmt.executeBatch();
stmt.close();
} }

View File

@@ -1,9 +1,15 @@
package de.jatitv.commandguiv2.Spigot.system.database; package de.jatitv.commandguiv2.Spigot.system.database;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.Load;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.sql.SQLException;
public class SelectDatabase { public class SelectDatabase {
private static StorageType Storage; private static StorageType Storage;
@@ -19,7 +25,12 @@ public class SelectDatabase {
public static void nameCheck(Player player) { public static void nameCheck(Player player) {
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); try {
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break; break;
case YML: case YML:
@@ -34,8 +45,13 @@ public class SelectDatabase {
public static void setSlot(Player player, Integer slot) { public static void setSlot(Player player, Integer slot) {
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() try {
+ "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';"); MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break; break;
case YML: case YML:
YML.setGuiitemSlot(player, slot); YML.setGuiitemSlot(player, slot);
@@ -49,11 +65,16 @@ public class SelectDatabase {
} }
public static void setItemStatusTrue(Player player) { public static void setItemStatusTrue(Player player) {
Events.useItemHashMap.replace(player, true); Events.useItemHashMap.replace(player.getName(), true);
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() try {
+ "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';"); MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break; break;
case YML: case YML:
YML.setGuiitemOn(player); YML.setGuiitemOn(player);
@@ -67,11 +88,16 @@ public class SelectDatabase {
} }
public static void setItemStatusFalse(Player player) { public static void setItemStatusFalse(Player player) {
Events.useItemHashMap.replace(player, false); Events.useItemHashMap.replace(player.getName(), false);
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() try {
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';"); MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break; break;
case YML: case YML:
YML.setGuiitemOff(player); YML.setGuiitemOff(player);

View File

@@ -1,6 +1,8 @@
package de.jatitv.commandguiv2.Spigot.system.database; package de.jatitv.commandguiv2.Spigot.system.database;
import de.jatitv.commandguiv2.Spigot.Main; 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 net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -45,6 +47,7 @@ public class YML {
try { try {
yamlConfigurationStorage.save(storage); yamlConfigurationStorage.save(storage);
} catch (IOException e) { } catch (IOException e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@@ -1,8 +1,11 @@
package de.jatitv.commandguiv2; package de.jatitv.commandguiv2;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
public class Util { public class Util {
private static Integer configVersion = 5; private static Integer configVersion = 5;
private static double requiredT2CodeLibVersion = 10.3; private static double requiredT2CodeLibVersion = 11.9;
private static String Prefix = "§8[§4C§9GUI§8]"; private static String Prefix = "§8[§4C§9GUI§8]";
private static Integer SpigotID = 90671; private static Integer SpigotID = 90671;
private static Integer BstatsID = 10840; private static Integer BstatsID = 10840;
@@ -36,4 +39,8 @@ public class Util {
public static Integer getConfigVersion() { public static Integer getConfigVersion() {
return configVersion; return configVersion;
} }
public static void sendTryCatch(Class c, StackTraceElement line){
send.error(Main.plugin, c.getName() + " Line: " + line.getLineNumber());
}
} }

View File

@@ -44,11 +44,11 @@ public class CGuiAPI {
} }
public static Boolean selectPlayerItemEnable(Player player) { public static Boolean selectPlayerItemEnable(Player player) {
return Events.useItemHashMap.get(player); return Events.useItemHashMap.get(player.getName());
} }
public static Integer selectPlayerItemSlot(Player player) { public static Integer selectPlayerItemSlot(Player player) {
return Events.useItemSlotHashMap.get(player); return Events.useItemSlotHashMap.get(player.getName());
} }
public static void setPlayerItemEnable(Player player, Boolean value) { public static void setPlayerItemEnable(Player player, Boolean value) {

View File

@@ -21,52 +21,3 @@ commands:
aliases: [cguihelp, guihelp] aliases: [cguihelp, guihelp]
commandgui-item: commandgui-item:
aliases: [gui-item] aliases: [gui-item]
#permissions:
# commandgui.admin:
# description: All permissions from CommandGUI
# default: op
# children:
# commandgui.command: true
# commandgui.get.guiitem.at.login: true
# commandgui.useitem: true
# commandgui.useitem.toggle: true
# commandgui.updatemsg: true
# commandgui.bypass: true
# commandgui.command.info: true
# commandgui.command.give: true
#
# commandgui.player:
# description: All permissions from CommandGUI
# default: op
# children:
# commandgui.command: true
# commandgui.get.guiitem.at.login: true
# commandgui.useitem: true
# commandgui.useitem.toggle: true
#
# commandgui.updatemsg:
# description: Players with this permission get the update message when joining if an update is available
# default: op
# commandgui.command:
# description: Required permission to open GUIs via command
# default: op
# commandgui.get.guiitem.at.login:
# description: Only players with this permission will receive the GUI item
# default: op
# commandgui.useitem:
# description: Required permission to use the GUI Item
# default: op
# commandgui.useitem.toggle:
# description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)
# default: op
# commandgui.bypass:
# description: Bypass to open disabled GUIs
# default: op
# commandgui.command.info:
# description: Permission to view CommandGUI info
# default: not op
# commandgui.command.give:
# description: Kommend in V2.1.0
# default: op

View File

@@ -54,3 +54,4 @@ Optional:
--- ---
<img src="https://bstats.org/signatures/bukkit/CGUI.svg" width="600"> <img src="https://bstats.org/signatures/bukkit/CGUI.svg" width="600">
<img src="https://i.imgur.com/tVLZGZg.png" width="600">