Compare commits

...

10 Commits

Author SHA1 Message Date
JaTiTV b6347c8fad 2.7.0 2 months ago
JaTiTV f3feddd317 api changes & clean code 2 months ago
JaTiTV 35a9930017 error fix 2 months ago
JaTiTV fc98f931e2 Bugfix 2 months ago
JaTiTV cfd07b01f2 2.7.0_Snapshot-6 | Fix 2 months ago
JaTiTV c5bc880ab1 Add SQLITE & Bugfix 2 months ago
JaTiTV 3bd0662273 fix use and see perm 2 months ago
JaTiTV 7993dca126 refresh perms by reload 2 months ago
JaTiTV 520df8dc97 2.7.0_Snapshot-3 | Perm Update 2 months ago
JaTiTV 8e90aee0ca 2.7.0_Snapshot-2 | small change 2 months ago
  1. 19
      CommandGUI V2/pom.xml
  2. 69
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java
  3. 55
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java
  4. 4
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java
  5. 72
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java
  6. 2
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/EventsFrom110.java
  7. 100
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Commands.java
  8. 9
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Help.java
  9. 2
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java
  10. 12
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java
  11. 5
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java
  12. 21
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java
  13. 4
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java
  14. 8
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java
  15. 6
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java
  16. 37
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java
  17. 42
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java
  18. 6
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java
  19. 36
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java
  20. 89
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Load.java
  21. 11
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Metrics.java
  22. 77
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Permissions.java
  23. 26
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java
  24. 64
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/UseItem.java
  25. 4
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java
  26. 135
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java
  27. 127
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SelectDatabase.java
  28. 72
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/Select_Database.java
  29. 7
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/StorageType.java
  30. 23
      CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java
  31. 96
      CommandGUI V2/src/main/resources/plugin.yml

19
CommandGUI V2/pom.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.7.0_Snapshot-1</version>
<version>2.7.0</version>
<packaging>jar</packaging>
<name>CommandGUI</name>
@ -67,9 +67,8 @@ @@ -67,9 +67,8 @@
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
@ -86,7 +85,7 @@ @@ -86,7 +85,7 @@
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>11.4</version>
<version>11.6</version>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
@ -113,12 +112,6 @@ @@ -113,12 +112,6 @@
<artifactId>HikariCP</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
@ -129,5 +122,11 @@ @@ -129,5 +122,11 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.22</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

69
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java → CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java

@ -31,7 +31,7 @@ import org.bukkit.scheduler.BukkitRunnable; @@ -31,7 +31,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.io.IOException;
public class GUI_Listener implements Listener {
public class GUIListener implements Listener {
private static String prefix = Util.getPrefix();
public static String GUICode;
@ -44,24 +44,25 @@ public class GUI_Listener implements Listener { @@ -44,24 +44,25 @@ public class GUI_Listener implements Listener {
if (e.getInventory() == null) return;
if (e.getCurrentItem() == null) return;
for (Gui gui : Main.guiHashMap.values()) {
if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name))
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) {
if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.guiName))
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.guiName)))) {
e.setCancelled(true);
for (Slot slot : gui.slots) {
Function function = Main.functionHashMap.get(slot.function);
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.permission || !player.hasPermission(slot.permissionToUse)) {
player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name))
.replace("[perm]", slot.permissionToUse));
continue;
}
if (!slot.enable) continue;
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, function.name))) continue;
if (function.cost_Enable) {
if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) {
if (!Vault.buy(prefix, player, function.price)) {
new BukkitRunnable() {
@Override
@ -78,7 +79,9 @@ public class GUI_Listener implements Listener { @@ -78,7 +79,9 @@ public class GUI_Listener implements Listener {
execute(function, slot, player, e, gui);
}
}
} else execute(function, slot, player, e, gui);
} else {
execute(function, slot, player, e, gui);
}
}
}
}
@ -86,8 +89,8 @@ public class GUI_Listener implements Listener { @@ -86,8 +89,8 @@ public class GUI_Listener implements Listener {
}
private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) {
if (function.togglePermission) togglePerm(function, player);
if (function.toggleUseItem) toggleUseItem(player);
if (function.togglePermission) togglePerm(function, gui, player);
if (function.toggleUseItem) toggleUseItem(player, gui);
if (function.command_Enable) command(function, player);
if (function.openGUI_Enable) openGUI(function, player);
if (function.message_Enable) message(function, player);
@ -131,7 +134,7 @@ public class GUI_Listener implements Listener { @@ -131,7 +134,7 @@ public class GUI_Listener implements Listener {
new BukkitRunnable() {
@Override
public void run() {
OpenGUI.openGUI(player, slot.openGUI);
OpenGUI.openGUI(player, slot.openGUI, true);
}
}.runTaskLater(plugin, 1L);
}
@ -227,26 +230,48 @@ public class GUI_Listener implements Listener { @@ -227,26 +230,48 @@ public class GUI_Listener implements Listener {
if (!function.customSound_NoSound) {
try {
player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound));
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.guiName) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound));
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
}
}
} else player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
private static void togglePerm(Function slot, Player player) {
if (player.hasPermission(slot.togglePermissionPerm)) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm));
private static void togglePerm(Function function, Gui gui, Player player) {
if (player.hasPermission(function.togglePermissionPerm)) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
OpenGUI.openGUI(player, gui.key, false);
}
}.runTaskLater(plugin, 4L);
} else
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm));
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
OpenGUI.openGUI(player, gui.key, false);
}
}.runTaskLater(plugin, 4L);
}
private static void toggleUseItem(Player player) {
private static void toggleUseItem(Player player, Gui gui) {
if (Events.useItemHashMap.get(player)) {
Commands.itemOff(player);
} else Commands.itemOn(player);
} else {
Commands.itemOn(player);
}
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
OpenGUI.openGUI(player, gui.key, false);
}
}.runTaskLater(plugin, 2L);
}
}

55
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java

@ -2,14 +2,10 @@ package de.jatitv.commandguiv2.Spigot.Listener; @@ -2,14 +2,10 @@ package de.jatitv.commandguiv2.Spigot.Listener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.system.Give_UseItem;
import de.jatitv.commandguiv2.Spigot.system.UseItem;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class ItemChange {
@ -28,37 +24,15 @@ public class ItemChange { @@ -28,37 +24,15 @@ public class ItemChange {
if (!SelectConfig.UseItem_Enable) {
return;
}
if (SelectConfig.UseItemGameModeProtection) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
if (SelectConfig.UseItemGameModeRemoveItemWhenItIsDisabled) removeItem(player);
send.debug(Main.plugin,"GameMode disabled: " +player.getName() +" " +player.getGameMode().toString());
return;
}
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
if (SelectConfig.UseItemGameModeRemoveItemWhenItIsDisabled) removeItem(player);
send.debug(Main.plugin,"GameMode disabled: " +player.getName() +" " +player.getGameMode().toString());
return;
}
}
if (SelectConfig.UseItemWorldProtection) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
if (SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled)removeItem(player);
send.debug(Main.plugin,"World disabled: " +player.getName() +" " +player.getWorld().toString());
return;
}
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
if (SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled)removeItem(player);
send.debug(Main.plugin,"World disabled: " +player.getName() +" " +player.getWorld().toString());
return;
}
}
UseItem.removeItem(player);
if (UseItem.protection(player, false)) return;
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
if (!player.hasPlayedBefore()) {
new BukkitRunnable() {
@Override
public void run() {
Give_UseItem.onGive(player);
UseItem.giveUseItem(player);
if (setCursor) {
setCursor(player, slot);
}
@ -79,11 +53,10 @@ public class ItemChange { @@ -79,11 +53,10 @@ public class ItemChange {
new BukkitRunnable() {
@Override
public void run() {
removeItem(player);
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
send.debug(Main.plugin,"Give: " +player.getName());
Give_UseItem.onGive(player);
UseItem.giveUseItem(player);
if (setCursor) {
setCursor(player, slot);
}
@ -96,7 +69,7 @@ public class ItemChange { @@ -96,7 +69,7 @@ public class ItemChange {
}
}
if (empty) {
Give_UseItem.onGiveADD(player);
UseItem.addUseItem(player);
}
}
}
@ -140,20 +113,4 @@ public class ItemChange { @@ -140,20 +113,4 @@ public class ItemChange {
Main.bungeejoinplayers.remove(player.getName());
}
}
private static void removeItem(Player player) {
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
player.getInventory().remove(itm);
player.updateInventory();
break;
}
}
}
}
}
}

4
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java

@ -4,7 +4,7 @@ package de.jatitv.commandguiv2.Spigot.Listener; @@ -4,7 +4,7 @@ package de.jatitv.commandguiv2.Spigot.Listener;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
@ -22,7 +22,7 @@ public class PluginEvent implements Listener { @@ -22,7 +22,7 @@ public class PluginEvent implements Listener {
@EventHandler
public void onJoinEvent(PlayerLoginEvent event) {
Player player = event.getPlayer();
Select_Database.nameCheck(player);
SelectDatabase.nameCheck(player);
UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
}

72
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java

@ -6,7 +6,8 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands; @@ -6,7 +6,8 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
import de.jatitv.commandguiv2.Spigot.system.UseItem;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.api.CGuiAPI;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -35,23 +36,24 @@ public class Events implements Listener { @@ -35,23 +36,24 @@ public class Events implements Listener {
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>();
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>();
@EventHandler
public void onJoin(PlayerJoinEvent e) {
if (Select_Database.selectItemStatus(e.getPlayer())){
if (SelectDatabase.selectItemStatus(e.getPlayer())) {
useItemHashMap.put(e.getPlayer(), true);
} else useItemHashMap.put(e.getPlayer(), false);
useItemSlotHashMap.put(e.getPlayer(),Select_Database.selectSlot(e.getPlayer()));
useItemSlotHashMap.put(e.getPlayer(), SelectDatabase.selectSlot(e.getPlayer()));
if (CGuiAPI.JoinDisable) {
send.debug(Main.plugin,"JoinDisable");
send.debug(Main.plugin, "JoinDisable");
return;
}
if (e.getPlayer().hasPermission("commandgui.get.guiitem.at.login")) {
new BukkitRunnable() {
@Override
public void run() {
send.debug(Main.plugin,"itemChange: " + e.getPlayer().getName());
send.debug(Main.plugin, "itemChange: " + e.getPlayer().getName());
ItemChange.itemChange(e.getPlayer(), true);
}
}.runTaskLater(Main.plugin, 20L * 1);
@ -66,18 +68,7 @@ public class Events implements Listener { @@ -66,18 +68,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onDeathDrop(PlayerDeathEvent e) {
Player player = e.getEntity().getPlayer();
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
player.getInventory().remove(itm);
player.updateInventory();
break;
}
}
}
}
UseItem.removeItem(player);
if (!e.getDrops().isEmpty()) {
Iterator var3 = (new ArrayList(e.getDrops())).iterator();
while (var3.hasNext()) {
@ -166,47 +157,50 @@ public class Events implements Listener { @@ -166,47 +157,50 @@ public class Events implements Listener {
}
}
private static void openGUI(PlayerInteractEvent e, Player p) {
private static void openGUI(PlayerInteractEvent e, Player player) {
e.setCancelled(true);
if (p.isSneaking()) {
Commands.info(p);
if (SelectConfig.disableInfoBySneak && player.isSneaking()) {
Commands.info(player);
return;
}
if (!legacy()) {
if (!topInventoryIsEmpty(p)) return;
if (!topInventoryIsEmpty(player)) return;
}
if (UseItem.protection(player, true)) return;
if (SelectConfig.UseItemGameModeProtection) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(p.getGameMode().toString())) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
e.setCancelled(true);
send.player(p, SelectMessages.UseItemDisabledInGameMode);
send.player(player, SelectMessages.UseItemDisabledInGameMode);
return;
}
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(p.getGameMode().toString())) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
e.setCancelled(true);
send.player(p, SelectMessages.UseItemDisabledInGameMode);
send.player(player, SelectMessages.UseItemDisabledInGameMode);
return;
}
}
if (SelectConfig.UseItemWorldProtection) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(p.getWorld().getName())) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
e.setCancelled(true);
send.player(p, SelectMessages.UseItemDisabledInWorld);
send.player(player, SelectMessages.UseItemDisabledInWorld);
return;
}
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(p.getWorld().getName())) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
e.setCancelled(true);
send.player(p, SelectMessages.UseItemDisabledInWorld);
send.player(player, SelectMessages.UseItemDisabledInWorld);
return;
}
}
if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true);
} else {
p.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
player.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
.replace("[gui]", SelectConfig.UseItem_OpenGUI));
}
}
@ -225,6 +219,7 @@ public class Events implements Listener { @@ -225,6 +219,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryDragEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getWhoClicked() instanceof Player) {
Player p = (Player) e.getWhoClicked();
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
@ -246,7 +241,6 @@ public class Events implements Listener { @@ -246,7 +241,6 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemMove(InventoryClickEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
Player player = (Player) e.getWhoClicked();
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
@ -256,13 +250,13 @@ public class Events implements Listener { @@ -256,13 +250,13 @@ public class Events implements Listener {
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryPickupItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getItem() != null && e.getItem().getItemStack() != null) {
ItemStack item = e.getItem().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
@ -275,6 +269,7 @@ public class Events implements Listener { @@ -275,6 +269,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
e.setCancelled(true);
@ -284,6 +279,7 @@ public class Events implements Listener { @@ -284,6 +279,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onDrop(PlayerDropItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
ItemStack item = e.getItemDrop().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
@ -294,7 +290,7 @@ public class Events implements Listener { @@ -294,7 +290,7 @@ public class Events implements Listener {
}
private static boolean legacy() {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15|| NMSVersion.v1_16_R1) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) {
return true;
} else return false;
}

2
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events_from1_10.java → CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/EventsFrom110.java

@ -8,7 +8,7 @@ import org.bukkit.event.EventPriority; @@ -8,7 +8,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.*;
public class Events_from1_10 implements Listener {
public class EventsFrom110 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onHandSwap(PlayerSwapHandItemsEvent e) {

100
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Commands.java

@ -6,12 +6,13 @@ import de.jatitv.commandguiv2.Spigot.objects.Obj_Select; @@ -6,12 +6,13 @@ import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.system.Give_UseItem;
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.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -22,6 +23,8 @@ import org.bukkit.command.CommandSender; @@ -22,6 +23,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
public class Commands {
public static void info(CommandSender sender) {
if (sender instanceof Player) {
@ -64,8 +67,12 @@ public class Commands { @@ -64,8 +67,12 @@ public class Commands {
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
ConfigCreate.configCreate();
SelectConfig.onSelect();
Main.plugin.reloadConfig();
Main.plugin.reloadConfig();
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!");
send.console("You have changed the storage medium! To apply this change, you must restart the server!");
}
LanguagesCreate.langCreate();
Obj_Select.onSelect();
@ -77,6 +84,11 @@ public class Commands { @@ -77,6 +84,11 @@ public class Commands {
} catch (Exception e) {
e.printStackTrace();
}
try {
Permissions.onPermRegister();
} catch (Exception e) {
e.printStackTrace();
}
if (SelectConfig.Bungee) {
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee");
@ -91,7 +103,7 @@ public class Commands { @@ -91,7 +103,7 @@ public class Commands {
public static void give(CommandSender sender, Player target) {
if (Bukkit.getPlayer(target.getName()) != null) {
Give_UseItem.onGive(target);
UseItem.giveUseItem(target);
send.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.UseItem_Name));
send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.UseItem_Name));
if (SelectConfig.Sound_Give_Enable && SelectConfig.Sound_Enable) {
@ -107,18 +119,7 @@ public class Commands { @@ -107,18 +119,7 @@ public class Commands {
}
public static void itemOn(Player player) {
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
player.getInventory().remove(itm);
player.updateInventory();
break;
}
}
}
}
UseItem.removeItem(player);
Integer slot = null;
if (SelectConfig.UseItem_InventorySlotEnforce) {
slot = SelectConfig.UseItem_InventorySlot;
@ -131,8 +132,8 @@ public class Commands { @@ -131,8 +132,8 @@ public class Commands {
}
send.debug(Main.plugin, String.valueOf(slot));
if (player.getInventory().getItem(slot - 1) == null) {
Select_Database.setItemStatusTrue(player);
Give_UseItem.onGive(player);
SelectDatabase.setItemStatusTrue(player);
UseItem.giveUseItem(player);
} else {
boolean empty = false;
for (int i = 0; i < 9; i++) {
@ -142,8 +143,8 @@ public class Commands { @@ -142,8 +143,8 @@ public class Commands {
}
}
if (empty) {
Select_Database.setItemStatusTrue(player);
Give_UseItem.onGiveADD(player);
SelectDatabase.setItemStatusTrue(player);
UseItem.addUseItem(player);
send.player(player, SelectMessages.ItemON);
} else {
player.sendMessage(SelectMessages.NoInventorySpace);
@ -155,19 +156,8 @@ public class Commands { @@ -155,19 +156,8 @@ public class Commands {
}
public static void itemOff(Player player) {
Select_Database.setItemStatusFalse(player);
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
player.getInventory().remove(itm);
player.updateInventory();
send.player(player, SelectMessages.ItemOFF);
}
}
}
}
SelectDatabase.setItemStatusFalse(player);
UseItem.removeItem(player);
}
public static void onSetSlot(Player player, Integer setSlot) {
@ -180,7 +170,7 @@ public class Commands { @@ -180,7 +170,7 @@ public class Commands {
send.player(player, SelectMessages.ItemSlot_wrongValue);
return;
}
ItemStack itm1 = player.getInventory().getItem(setSlot - 1);
ItemStack itm1 = player.getInventory().getItem(setSlot + 1);
if (itm1 != null) {
if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) {
if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
@ -193,21 +183,11 @@ public class Commands { @@ -193,21 +183,11 @@ public class Commands {
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
return;
}
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
player.getInventory().remove(itm);
player.updateInventory();
break;
}
}
}
}
Select_Database.setSlot(player, setSlot);
UseItem.removeItem(player);
SelectDatabase.setSlot(player, setSlot);
Events.useItemSlotHashMap.replace(player, setSlot);
if (Events.useItemHashMap.get(player)) {
Give_UseItem.onGive(player);
UseItem.giveUseItem(player);
}
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
} else player.sendMessage(Util.getPrefix() + " §4Function disabled");
@ -216,30 +196,24 @@ public class Commands { @@ -216,30 +196,24 @@ public class Commands {
public static void gui(Player player) {
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, SelectConfig.DefaultGUI);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, SelectConfig.DefaultGUI, true);
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
.replace("[perm]", "commandgui.command"));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
}
}
public static void gui(Player player, String arg) {
if (Main.guiHashMap.containsKey(arg)) {
Gui gui = Main.guiHashMap.get(arg);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, arg);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.Command_Command)
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, arg, true);
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key)
.replace("[perm]", "commandgui.command." + arg.toLowerCase()));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.Command_Command));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.key));
} else player.sendMessage(SelectMessages.GUInotFound);
}
}

9
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Help.java

@ -15,10 +15,10 @@ public class Help { @@ -15,10 +15,10 @@ public class Help {
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
if (sender.hasPermission("commandgui.command")) {
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.GUI_Name)));
send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.guiName)));
for (String alias : Main.allAliases) {
if (Main.guiHashMap.get(alias).GUI_Enable || sender.hasPermission("commandgui.bypass")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix,Main.guiHashMap.get(alias).GUI_Name)));
if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix,Main.guiHashMap.get(alias).guiName)));
}
}
send.sender(sender, Prefix + " " + SelectMessages.HelpHelp);
@ -31,9 +31,6 @@ public class Help { @@ -31,9 +31,6 @@ public class Help {
if (sender.hasPermission("commandgui.command.info")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpInfo);
}
// if (sender.hasPermission("commandgui.command.give")) {
// send.sender(sender, Prefix + " " + Select_msg.HelpGive);
// }
if (sender.hasPermission("commandgui.admin")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath()+ "\\GUIs\\default.yml"));
send.sender(sender, Prefix + " " + SelectMessages.HelpReload);

2
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java

@ -23,7 +23,7 @@ public class AliasRegister { @@ -23,7 +23,7 @@ public class AliasRegister {
}
for (String alias : Main.allAliases) {
if (Main.guiHashMap.get(alias) != null) {
if (Main.guiHashMap.get(alias).Command_Alias_Enable) {
if (Main.guiHashMap.get(alias).commandAliasEnable) {
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");

12
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java

@ -4,7 +4,6 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register; @@ -4,7 +4,6 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -24,15 +23,12 @@ public class RegisterCommand extends Command { @@ -24,15 +23,12 @@ public class RegisterCommand extends Command {
if (sender instanceof Player) {
Player player = (Player) sender;
Gui gui = Main.guiHashMap.get(alias);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, alias);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, alias, true);
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias)
.replace("[perm]", "commandgui.command." + alias));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name));
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
} else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!");
return true;
}

5
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java

@ -26,15 +26,13 @@ public class ConfigCreate { @@ -26,15 +26,13 @@ public class ConfigCreate {
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration);
Config.set("Plugin.Debug", false, yamlConfiguration);
Config.set("Plugin.HelpAlias", true, yamlConfiguration);
Config.set("Plugin.language", "english", yamlConfiguration);
Config.set("Plugin.Currency", "$", yamlConfiguration);
Config.set("Plugin.DefaultGUI", "default", yamlConfiguration);
Config.set("Storage.Type", "YML", yamlConfiguration);
Config.set("Storage.Type", "SQLITE", yamlConfiguration);
Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration);
Config.set("Storage.MySQL.Port", 3306, yamlConfiguration);
Config.set("Storage.MySQL.Database", "database", yamlConfiguration);
@ -102,7 +100,6 @@ public class ConfigCreate { @@ -102,7 +100,6 @@ public class ConfigCreate {
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);

21
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java

@ -4,6 +4,8 @@ import de.jatitv.commandguiv2.Spigot.Main; @@ -4,6 +4,8 @@ import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
@ -20,16 +22,12 @@ public class SelectConfig { @@ -20,16 +22,12 @@ public class SelectConfig {
private static final File config = new File(Main.getPath(), "config.yml");
private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
public static Boolean DisableUpdateChecker;
public static Boolean UpdateCheckOnJoin;
public static Boolean Debug;
public static Boolean HelpAlias;
public static String language;
public static String Currency;
public static List<String> mainCommands;
public static String Storage;
public static String storage;
public static Boolean Bungee;
public static String thisServer;
@ -63,6 +61,8 @@ public class SelectConfig { @@ -63,6 +61,8 @@ public class SelectConfig {
public static String UseItemWorldMode;
public static List<String> UseItemWorldList;
public static Boolean disableInfoBySneak;
public static Boolean UseItem_InventorySlot_FreeSlot;
public static Integer UseItem_InventorySlot;
public static Boolean UseItem_InventorySlotEnforce;
@ -128,18 +128,12 @@ public class SelectConfig { @@ -128,18 +128,12 @@ public class SelectConfig {
}
}
if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) {
DisableUpdateChecker = false;
} else DisableUpdateChecker = yamlConfiguration.getBoolean("Plugin.DisableUpdateChecker");
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin");
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
HelpAlias = yamlConfiguration.getBoolean("Plugin.HelpAlias");
language = yamlConfiguration.getString("Plugin.language");
Currency = yamlConfiguration.getString("Plugin.Currency");
DefaultGUI = yamlConfiguration.getString("Plugin.DefaultGUI");
Storage = yamlConfiguration.getString("Storage.Type").toUpperCase();
storage = yamlConfiguration.getString("Storage.Type").toUpperCase();
MySQL.ip = yamlConfiguration.getString("Storage.MySQL.IP");
MySQL.port = yamlConfiguration.getInt("Storage.MySQL.Port");
@ -195,6 +189,9 @@ public class SelectConfig { @@ -195,6 +189,9 @@ public class SelectConfig {
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null){
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
}
toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable");
toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value");

4
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java

@ -152,8 +152,8 @@ public class ConfigConverterUnderV5 { @@ -152,8 +152,8 @@ public class ConfigConverterUnderV5 {
set("Slots." + key + ".Enable", slotEnable, yamlConfiguration);
set("Slots." + key + ".Function", function, yamlConfiguration);
set("Slots." + key + ".Permission.Required", permRequired, yamlConfiguration);
set("Slots." + key + ".Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
set("Slots." + key + ".Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
set("Slots." + key + ".Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration);
set("Slots." + key + ".Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration);
}
private static void set(String path, String value, YamlConfiguration config) {

8
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java

@ -33,15 +33,15 @@ public class CreateGUI { @@ -33,15 +33,15 @@ public class CreateGUI {
set("Slots.SupportDiscord.Enable", true, yamlConfiguration);
set("Slots.SupportDiscord.Function", "SupportDiscord", yamlConfiguration);
set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration);
set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration);
set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration);
set("Slots.UseItem.Slot", 6, yamlConfiguration);
set("Slots.UseItem.Enable", true, yamlConfiguration);
set("Slots.UseItem.Function", "UseItem", yamlConfiguration);
set("Slots.UseItem.Permission.Required", false, yamlConfiguration);
set("Slots.UseItem.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
set("Slots.UseItem.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
set("Slots.UseItem.Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration);
set("Slots.UseItem.Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration);
try {

6
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java

@ -109,13 +109,13 @@ public class GuiBuilder { @@ -109,13 +109,13 @@ public class GuiBuilder {
public static void fillItem(Inventory inventory, Gui gui) {
ItemStack glass;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item));
} else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_")));
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.guiFillItemItem));
} else glass = new ItemStack(Material.valueOf(gui.guiFillItemItem.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta();
itemMetaglass.setDisplayName(" ");
glass.setItemMeta(itemMetaglass);
glass.setAmount(1);
for (int i = 0; i < 9 * gui.GUI_Lines; i++) {
for (int i = 0; i < 9 * gui.guiLines; i++) {
inventory.setItem(i, glass);
}
}

37
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package de.jatitv.commandguiv2.Spigot.gui;
import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener;
import de.jatitv.commandguiv2.Spigot.Listener.GUIListener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
@ -26,7 +26,7 @@ public class OpenGUI { @@ -26,7 +26,7 @@ public class OpenGUI {
private static Plugin plugin = Main.plugin;
private static String prefix = Util.getPrefix();
public static void openGUI(Player player, String guiString) {
public static void openGUI(Player player, String guiString, Boolean sound) {
Gui gui = Main.guiHashMap.get(guiString);
Long long_ = Long.valueOf(System.currentTimeMillis());
switch (guiString) {
@ -63,20 +63,26 @@ public class OpenGUI { @@ -63,20 +63,26 @@ public class OpenGUI {
}
if (MCVersion.minecraft1_13) {
GUI_Listener.GUICode = "";
} else GUI_Listener.GUICode = "§6§8§9§r";
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
GUIListener.GUICode = "";
} else GUIListener.GUICode = "§6§8§9§r";
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
Inventory inventory;
if (Main.PaPi) {
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name)));
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name)));
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, player, GUIListener.GUICode + gui.guiName)));
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, GUIListener.GUICode + gui.guiName)));
if (gui.GUI_FillItem_Enable) {
if (gui.guiFillItemEnable) {
GuiBuilder.fillItem(inventory, gui);
}
for (Slot slot : gui.slots) {
Function function = Main.functionHashMap.get(slot.function);
if (slot.permission || !player.hasPermission(slot.permissionToSee)) continue;
if (function == null) {
send.error(Main.plugin, "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!");
continue;
}
if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue;
if (slot.slot < 0 || slot.slot > gui.guiLines * 9) continue;
if (slot.enable) {
if (function.empty) {
ItemStack air = new ItemStack(Material.AIR);
@ -98,9 +104,9 @@ public class OpenGUI { @@ -98,9 +104,9 @@ public class OpenGUI {
if (function.playerHead_Enable) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" +
Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
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.GUI_Name).toString() + " §bSlot: §6" +
send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.guiName).toString() + " §bSlot: §6" +
(slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
} else {
if (function.base64_Enable) {
@ -121,9 +127,14 @@ public class OpenGUI { @@ -121,9 +127,14 @@ public class OpenGUI {
}
}
if (sound) {
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
}
player.openInventory(inventory);
send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name)));
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)));
}
private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) {

42
CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java

@ -5,6 +5,7 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; @@ -5,6 +5,7 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.configuration.file.YamlConfiguration;
@ -16,8 +17,8 @@ import java.util.Objects; @@ -16,8 +17,8 @@ import java.util.Objects;
public class Obj_Select {
public static void onSelect() {
onSelectGui();
onSelectFunction();
onSelectGui();
}
public static void onSelectGui() {
@ -29,9 +30,9 @@ public class Obj_Select { @@ -29,9 +30,9 @@ public class Obj_Select {
for (File config_gui : fileArray) {
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (sub.equals(".yml")) {
Main.allAliases.add(config_gui.getName().replace(".yml", ""));
String key = config_gui.getName().replace(".yml", "");
Main.allAliases.add(key);
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui);
String guiFileName = config_gui.getName().replace(".yml", "");
Boolean guiEnable = yamlConfiguration_gui.