Compare commits
10 Commits
2.7.0_Snap
...
2.7.0
Author | SHA1 | Date |
---|---|---|
JaTiTV | b6347c8fad | |
JaTiTV | f3feddd317 | |
JaTiTV | 35a9930017 | |
JaTiTV | fc98f931e2 | |
JaTiTV | cfd07b01f2 | |
JaTiTV | c5bc880ab1 | |
JaTiTV | 3bd0662273 | |
JaTiTV | 7993dca126 | |
JaTiTV | 520df8dc97 | |
JaTiTV | 8e90aee0ca |
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>CommandGUI_V2</artifactId>
|
<artifactId>CommandGUI_V2</artifactId>
|
||||||
<version>2.7.0_Snapshot-1</version>
|
<version>2.7.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>CommandGUI</name>
|
<name>CommandGUI</name>
|
||||||
|
@ -67,9 +67,8 @@
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>placeholderapi</id>
|
<id>placeholderapi</id>
|
||||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -86,7 +85,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>11.4</version>
|
<version>11.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
|
@ -113,12 +112,6 @@
|
||||||
<artifactId>HikariCP</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<version>4.0.3</version>
|
<version>4.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>me.clip</groupId>
|
|
||||||
<artifactId>placeholderapi</artifactId>
|
|
||||||
<version>2.11.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
|
@ -129,5 +122,11 @@
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.22</version>
|
<version>1.7.22</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.11.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class GUI_Listener implements Listener {
|
public class GUIListener implements Listener {
|
||||||
|
|
||||||
private static String prefix = Util.getPrefix();
|
private static String prefix = Util.getPrefix();
|
||||||
public static String GUICode;
|
public static String GUICode;
|
||||||
|
@ -44,24 +44,25 @@ public class GUI_Listener implements Listener {
|
||||||
if (e.getInventory() == null) return;
|
if (e.getInventory() == null) return;
|
||||||
if (e.getCurrentItem() == null) return;
|
if (e.getCurrentItem() == null) return;
|
||||||
for (Gui gui : Main.guiHashMap.values()) {
|
for (Gui gui : Main.guiHashMap.values()) {
|
||||||
if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, 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.GUI_Name)))) {
|
|| (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);
|
Function function = Main.functionHashMap.get(slot.function);
|
||||||
if (e.getSlot() != slot.slot) continue;
|
if (e.getSlot() != slot.slot) continue;
|
||||||
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() ||
|
if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue;
|
||||||
e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() ||
|
if (slot.permission && !player.hasPermission(slot.permissionToUse)) {
|
||||||
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))
|
player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name))
|
||||||
.replace("[perm]", slot.permissionToUse));
|
.replace("[perm]", slot.permissionToUse));
|
||||||
continue;
|
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 (!slot.enable) continue;
|
||||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, function.name))) continue;
|
|
||||||
if (function.cost_Enable) {
|
if (function.cost_Enable) {
|
||||||
if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) {
|
if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) {
|
||||||
|
|
||||||
if (!Vault.buy(prefix, player, function.price)) {
|
if (!Vault.buy(prefix, player, function.price)) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,7 +79,9 @@ public class GUI_Listener implements Listener {
|
||||||
execute(function, slot, player, e, gui);
|
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) {
|
private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) {
|
||||||
if (function.togglePermission) togglePerm(function, player);
|
if (function.togglePermission) togglePerm(function, gui, player);
|
||||||
if (function.toggleUseItem) toggleUseItem(player);
|
if (function.toggleUseItem) toggleUseItem(player, gui);
|
||||||
if (function.command_Enable) command(function, player);
|
if (function.command_Enable) command(function, player);
|
||||||
if (function.openGUI_Enable) openGUI(function, player);
|
if (function.openGUI_Enable) openGUI(function, player);
|
||||||
if (function.message_Enable) message(function, player);
|
if (function.message_Enable) message(function, player);
|
||||||
|
@ -131,7 +134,7 @@ public class GUI_Listener implements Listener {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
OpenGUI.openGUI(player, slot.openGUI);
|
OpenGUI.openGUI(player, slot.openGUI, true);
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 1L);
|
}.runTaskLater(plugin, 1L);
|
||||||
}
|
}
|
||||||
|
@ -227,26 +230,48 @@ public class GUI_Listener implements Listener {
|
||||||
if (!function.customSound_NoSound) {
|
if (!function.customSound_NoSound) {
|
||||||
try {
|
try {
|
||||||
player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
|
player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
|
||||||
|
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
|
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);
|
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) {
|
private static void togglePerm(Function function, Gui gui, Player player) {
|
||||||
if (player.hasPermission(slot.togglePermissionPerm)) {
|
if (player.hasPermission(function.togglePermissionPerm)) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", slot.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
|
} 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)) {
|
if (Events.useItemHashMap.get(player)) {
|
||||||
Commands.itemOff(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,14 +2,10 @@ package de.jatitv.commandguiv2.Spigot.Listener;
|
||||||
|
|
||||||
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.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.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 net.t2code.lib.Spigot.Lib.messages.send;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class ItemChange {
|
public class ItemChange {
|
||||||
|
@ -28,37 +24,15 @@ public class ItemChange {
|
||||||
if (!SelectConfig.UseItem_Enable) {
|
if (!SelectConfig.UseItem_Enable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SelectConfig.UseItemGameModeProtection) {
|
UseItem.removeItem(player);
|
||||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
if (UseItem.protection(player, false)) return;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
|
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
|
||||||
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
|
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
|
||||||
if (!player.hasPlayedBefore()) {
|
if (!player.hasPlayedBefore()) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Give_UseItem.onGive(player);
|
UseItem.giveUseItem(player);
|
||||||
if (setCursor) {
|
if (setCursor) {
|
||||||
setCursor(player, slot);
|
setCursor(player, slot);
|
||||||
}
|
}
|
||||||
|
@ -79,11 +53,10 @@ public class ItemChange {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
removeItem(player);
|
|
||||||
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
|
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());
|
||||||
Give_UseItem.onGive(player);
|
UseItem.giveUseItem(player);
|
||||||
if (setCursor) {
|
if (setCursor) {
|
||||||
setCursor(player, slot);
|
setCursor(player, slot);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +69,7 @@ public class ItemChange {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty) {
|
if (empty) {
|
||||||
Give_UseItem.onGiveADD(player);
|
UseItem.addUseItem(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,20 +113,4 @@ public class ItemChange {
|
||||||
Main.bungeejoinplayers.remove(player.getName());
|
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,7 +4,7 @@ package de.jatitv.commandguiv2.Spigot.Listener;
|
||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.Main;
|
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.database.Select_Database;
|
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
|
||||||
import de.jatitv.commandguiv2.Util;
|
import de.jatitv.commandguiv2.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -22,7 +22,7 @@ public class PluginEvent implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoinEvent(PlayerLoginEvent event) {
|
public void onJoinEvent(PlayerLoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Select_Database.nameCheck(player);
|
SelectDatabase.nameCheck(player);
|
||||||
UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
|
UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.config.SelectConfig;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||||
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
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 de.jatitv.commandguiv2.api.CGuiAPI;
|
||||||
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;
|
||||||
|
@ -35,23 +36,24 @@ public class Events implements Listener {
|
||||||
|
|
||||||
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>();
|
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>();
|
||||||
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>();
|
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
if (Select_Database.selectItemStatus(e.getPlayer())){
|
if (SelectDatabase.selectItemStatus(e.getPlayer())) {
|
||||||
useItemHashMap.put(e.getPlayer(), true);
|
useItemHashMap.put(e.getPlayer(), true);
|
||||||
} else useItemHashMap.put(e.getPlayer(), false);
|
} 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) {
|
if (CGuiAPI.JoinDisable) {
|
||||||
send.debug(Main.plugin,"JoinDisable");
|
send.debug(Main.plugin, "JoinDisable");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.getPlayer().hasPermission("commandgui.get.guiitem.at.login")) {
|
if (e.getPlayer().hasPermission("commandgui.get.guiitem.at.login")) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
send.debug(Main.plugin,"itemChange: " + e.getPlayer().getName());
|
send.debug(Main.plugin, "itemChange: " + e.getPlayer().getName());
|
||||||
ItemChange.itemChange(e.getPlayer(), true);
|
ItemChange.itemChange(e.getPlayer(), true);
|
||||||
}
|
}
|
||||||
}.runTaskLater(Main.plugin, 20L * 1);
|
}.runTaskLater(Main.plugin, 20L * 1);
|
||||||
|
@ -66,18 +68,7 @@ public class Events implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDeathDrop(PlayerDeathEvent e) {
|
public void onDeathDrop(PlayerDeathEvent e) {
|
||||||
Player player = e.getEntity().getPlayer();
|
Player player = e.getEntity().getPlayer();
|
||||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
UseItem.removeItem(player);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!e.getDrops().isEmpty()) {
|
if (!e.getDrops().isEmpty()) {
|
||||||
Iterator var3 = (new ArrayList(e.getDrops())).iterator();
|
Iterator var3 = (new ArrayList(e.getDrops())).iterator();
|
||||||
while (var3.hasNext()) {
|
while (var3.hasNext()) {
|
||||||
|
@ -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);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if (p.isSneaking()) {
|
if (SelectConfig.disableInfoBySneak && player.isSneaking()) {
|
||||||
Commands.info(p);
|
Commands.info(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!legacy()) {
|
if (!legacy()) {
|
||||||
if (!topInventoryIsEmpty(p)) return;
|
if (!topInventoryIsEmpty(player)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UseItem.protection(player, true)) return;
|
||||||
|
|
||||||
if (SelectConfig.UseItemGameModeProtection) {
|
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);
|
e.setCancelled(true);
|
||||||
send.player(p, SelectMessages.UseItemDisabledInGameMode);
|
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||||
return;
|
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);
|
e.setCancelled(true);
|
||||||
send.player(p, SelectMessages.UseItemDisabledInGameMode);
|
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectConfig.UseItemWorldProtection) {
|
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);
|
e.setCancelled(true);
|
||||||
send.player(p, SelectMessages.UseItemDisabledInWorld);
|
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||||
return;
|
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);
|
e.setCancelled(true);
|
||||||
send.player(p, SelectMessages.UseItemDisabledInWorld);
|
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) {
|
|
||||||
OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI);
|
if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) {
|
||||||
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
|
OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true);
|
||||||
p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
|
player.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
|
||||||
.replace("[gui]", SelectConfig.UseItem_OpenGUI));
|
.replace("[gui]", SelectConfig.UseItem_OpenGUI));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,6 +219,7 @@ public class Events implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onItemMove(InventoryDragEvent e) {
|
public void onItemMove(InventoryDragEvent e) {
|
||||||
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
||||||
|
|
||||||
if (e.getWhoClicked() instanceof Player) {
|
if (e.getWhoClicked() instanceof Player) {
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
|
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
|
||||||
|
@ -246,7 +241,6 @@ public class Events implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onItemMove(InventoryClickEvent e) {
|
public void onItemMove(InventoryClickEvent e) {
|
||||||
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
||||||
Player player = (Player) e.getWhoClicked();
|
|
||||||
|
|
||||||
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
|
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
|
||||||
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||||
|
@ -256,13 +250,13 @@ public class Events implements Listener {
|
||||||
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||||
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onItemMove(InventoryPickupItemEvent e) {
|
public void onItemMove(InventoryPickupItemEvent e) {
|
||||||
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
||||||
|
|
||||||
if (e.getItem() != null && e.getItem().getItemStack() != null) {
|
if (e.getItem() != null && e.getItem().getItemStack() != null) {
|
||||||
ItemStack item = e.getItem().getItemStack();
|
ItemStack item = e.getItem().getItemStack();
|
||||||
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||||
|
@ -275,6 +269,7 @@ public class Events implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlace(BlockPlaceEvent e) {
|
public void onPlace(BlockPlaceEvent e) {
|
||||||
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
||||||
|
|
||||||
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
|
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
|
||||||
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
@ -284,6 +279,7 @@ public class Events implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDrop(PlayerDropItemEvent e) {
|
public void onDrop(PlayerDropItemEvent e) {
|
||||||
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
|
||||||
|
|
||||||
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
|
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
|
||||||
ItemStack item = e.getItemDrop().getItemStack();
|
ItemStack item = e.getItemDrop().getItemStack();
|
||||||
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||||
|
@ -294,7 +290,7 @@ public class Events implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean legacy() {
|
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;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
|
|
||||||
public class Events_from1_10 implements Listener {
|
public class EventsFrom110 implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onHandSwap(PlayerSwapHandItemsEvent e) {
|
public void onHandSwap(PlayerSwapHandItemsEvent e) {
|
|
@ -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.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.Give_UseItem;
|
import de.jatitv.commandguiv2.Spigot.system.UseItem;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
|
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.database.Select_Database;
|
import de.jatitv.commandguiv2.Spigot.system.Permissions;
|
||||||
|
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.items.ItemVersion;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||||
|
@ -22,6 +23,8 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
public static void info(CommandSender sender) {
|
public static void info(CommandSender sender) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
|
@ -64,8 +67,12 @@ public class Commands {
|
||||||
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
|
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
|
||||||
ConfigCreate.configCreate();
|
ConfigCreate.configCreate();
|
||||||
SelectConfig.onSelect();
|
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();
|
LanguagesCreate.langCreate();
|
||||||
|
|
||||||
Obj_Select.onSelect();
|
Obj_Select.onSelect();
|
||||||
|
@ -77,6 +84,11 @@ public class Commands {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Permissions.onPermRegister();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if (SelectConfig.Bungee) {
|
if (SelectConfig.Bungee) {
|
||||||
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee");
|
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee");
|
||||||
|
@ -91,7 +103,7 @@ public class Commands {
|
||||||
|
|
||||||
public static void give(CommandSender sender, Player target) {
|
public static void give(CommandSender sender, Player target) {
|
||||||
if (Bukkit.getPlayer(target.getName()) != null) {
|
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.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));
|
send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.UseItem_Name));
|
||||||
if (SelectConfig.Sound_Give_Enable && SelectConfig.Sound_Enable) {
|
if (SelectConfig.Sound_Give_Enable && SelectConfig.Sound_Enable) {
|
||||||
|
@ -107,18 +119,7 @@ public class Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void itemOn(Player player) {
|
public static void itemOn(Player player) {
|
||||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
UseItem.removeItem(player);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Integer slot = null;
|
Integer slot = null;
|
||||||
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
||||||
slot = SelectConfig.UseItem_InventorySlot;
|
slot = SelectConfig.UseItem_InventorySlot;
|
||||||
|
@ -131,8 +132,8 @@ public class Commands {
|
||||||
}
|
}
|
||||||
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) {
|
||||||
Select_Database.setItemStatusTrue(player);
|
SelectDatabase.setItemStatusTrue(player);
|
||||||
Give_UseItem.onGive(player);
|
UseItem.giveUseItem(player);
|
||||||
} else {
|
} else {
|
||||||
boolean empty = false;
|
boolean empty = false;
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
|
@ -142,8 +143,8 @@ public class Commands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty) {
|
if (empty) {
|
||||||
Select_Database.setItemStatusTrue(player);
|
SelectDatabase.setItemStatusTrue(player);
|
||||||
Give_UseItem.onGiveADD(player);
|
UseItem.addUseItem(player);
|
||||||
send.player(player, SelectMessages.ItemON);
|
send.player(player, SelectMessages.ItemON);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SelectMessages.NoInventorySpace);
|
player.sendMessage(SelectMessages.NoInventorySpace);
|
||||||
|
@ -155,19 +156,8 @@ public class Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void itemOff(Player player) {
|
public static void itemOff(Player player) {
|
||||||
Select_Database.setItemStatusFalse(player);
|
SelectDatabase.setItemStatusFalse(player);
|
||||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
UseItem.removeItem(player);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onSetSlot(Player player, Integer setSlot) {
|
public static void onSetSlot(Player player, Integer setSlot) {
|
||||||
|
@ -180,7 +170,7 @@ public class Commands {
|
||||||
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack itm1 = player.getInventory().getItem(setSlot - 1);
|
ItemStack itm1 = player.getInventory().getItem(setSlot + 1);
|
||||||
if (itm1 != null) {
|
if (itm1 != null) {
|
||||||
if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) {
|
if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) {
|
||||||
if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||||
|
@ -193,21 +183,11 @@ public class Commands {
|
||||||
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
|
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
UseItem.removeItem(player);
|
||||||
ItemStack itm = player.getInventory().getItem(iam);
|
SelectDatabase.setSlot(player, setSlot);
|
||||||
if (itm != null) {
|
Events.useItemSlotHashMap.replace(player, setSlot);
|
||||||
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);
|
|
||||||
if (Events.useItemHashMap.get(player)) {
|
if (Events.useItemHashMap.get(player)) {
|
||||||
Give_UseItem.onGive(player);
|
UseItem.giveUseItem(player);
|
||||||
}
|
}
|
||||||
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
|
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
|
||||||
} else player.sendMessage(Util.getPrefix() + " §4Function disabled");
|
} else player.sendMessage(Util.getPrefix() + " §4Function disabled");
|
||||||
|
@ -216,30 +196,24 @@ public class Commands {
|
||||||
public static void gui(Player player) {
|
public static void gui(Player player) {
|
||||||
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
|
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
|
||||||
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
|
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
|
||||||
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||||
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
|
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
|
||||||
OpenGUI.openGUI(player, SelectConfig.DefaultGUI);
|
OpenGUI.openGUI(player, SelectConfig.DefaultGUI, true);
|
||||||
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")
|
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
|
||||||
.replace("[perm]", "commandgui.command"));
|
.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) {
|
public static void gui(Player player, String arg) {
|
||||||
if (Main.guiHashMap.containsKey(arg)) {
|
if (Main.guiHashMap.containsKey(arg)) {
|
||||||
Gui gui = Main.guiHashMap.get(arg);
|
Gui gui = Main.guiHashMap.get(arg);
|
||||||
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||||
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) {
|
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) {
|
||||||
OpenGUI.openGUI(player, arg);
|
OpenGUI.openGUI(player, arg, true);
|
||||||
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
|
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key)
|
||||||
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
|
|
||||||
}
|
|
||||||
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.Command_Command)
|
|
||||||
.replace("[perm]", "commandgui.command." + arg.toLowerCase()));
|
.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);
|
} else player.sendMessage(SelectMessages.GUInotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,10 @@ public class Help {
|
||||||
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
|
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
|
||||||
if (sender.hasPermission("commandgui.command")) {
|
if (sender.hasPermission("commandgui.command")) {
|
||||||
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
|
Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
|
||||||
send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.GUI_Name)));
|
send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.guiName)));
|
||||||
for (String alias : Main.allAliases) {
|
for (String alias : Main.allAliases) {
|
||||||
if (Main.guiHashMap.get(alias).GUI_Enable || sender.hasPermission("commandgui.bypass")) {
|
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).GUI_Name)));
|
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);
|
send.sender(sender, Prefix + " " + SelectMessages.HelpHelp);
|
||||||
|
@ -31,9 +31,6 @@ public class Help {
|
||||||
if (sender.hasPermission("commandgui.command.info")) {
|
if (sender.hasPermission("commandgui.command.info")) {
|
||||||
send.sender(sender, Prefix + " " + SelectMessages.HelpInfo);
|
send.sender(sender, Prefix + " " + SelectMessages.HelpInfo);
|
||||||
}
|
}
|
||||||
// if (sender.hasPermission("commandgui.command.give")) {
|
|
||||||
// send.sender(sender, Prefix + " " + Select_msg.HelpGive);
|
|
||||||
// }
|
|
||||||
if (sender.hasPermission("commandgui.admin")) {
|
if (sender.hasPermission("commandgui.admin")) {
|
||||||
send.sender(sender, Prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath()+ "\\GUIs\\default.yml"));
|
send.sender(sender, Prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath()+ "\\GUIs\\default.yml"));
|
||||||
send.sender(sender, Prefix + " " + SelectMessages.HelpReload);
|
send.sender(sender, Prefix + " " + SelectMessages.HelpReload);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class AliasRegister {
|
||||||
}
|
}
|
||||||
for (String alias : Main.allAliases) {
|
for (String alias : Main.allAliases) {
|
||||||
if (Main.guiHashMap.get(alias) != null) {
|
if (Main.guiHashMap.get(alias) != null) {
|
||||||
if (Main.guiHashMap.get(alias).Command_Alias_Enable) {
|
if (Main.guiHashMap.get(alias).commandAliasEnable) {
|
||||||
try {
|
try {
|
||||||
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
|
||||||
import de.jatitv.commandguiv2.Spigot.Main;
|
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.config.SelectConfig;
|
|
||||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -24,15 +23,12 @@ public class RegisterCommand extends Command {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Gui gui = Main.guiHashMap.get(alias);
|
Gui gui = Main.guiHashMap.get(alias);
|
||||||
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||||
if (!gui.Command_Permission_Enable || 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);
|
OpenGUI.openGUI(player, alias, true);
|
||||||
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 " + alias)
|
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias)
|
||||||
.replace("[perm]", "commandgui.command." + 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!");
|
} else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,15 +26,13 @@ public class ConfigCreate {
|
||||||
|
|
||||||
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
||||||
|
|
||||||
|
|
||||||
Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration);
|
|
||||||
Config.set("Plugin.Debug", false, yamlConfiguration);
|
Config.set("Plugin.Debug", false, yamlConfiguration);
|
||||||
Config.set("Plugin.HelpAlias", true, yamlConfiguration);
|
Config.set("Plugin.HelpAlias", true, yamlConfiguration);
|
||||||
Config.set("Plugin.language", "english", yamlConfiguration);
|
Config.set("Plugin.language", "english", yamlConfiguration);
|
||||||
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", "YML", yamlConfiguration);
|
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);
|
||||||
|
@ -102,7 +100,6 @@ public class ConfigCreate {
|
||||||
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("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);
|
Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);
|
||||||
|
|
|
@ -4,6 +4,8 @@ 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;
|
||||||
|
@ -20,16 +22,12 @@ public class SelectConfig {
|
||||||
|
|
||||||
private static final File config = new File(Main.getPath(), "config.yml");
|
private static final File config = new File(Main.getPath(), "config.yml");
|
||||||
private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
public static Boolean DisableUpdateChecker;
|
|
||||||
public static Boolean UpdateCheckOnJoin;
|
|
||||||
public static Boolean Debug;
|
public static Boolean Debug;
|
||||||
public static Boolean HelpAlias;
|
public static Boolean HelpAlias;
|
||||||
public static String language;
|
public static String language;
|
||||||
public static String Currency;
|
public static String Currency;
|
||||||
public static List<String> mainCommands;
|
|
||||||
|
|
||||||
public static String Storage;
|
public static String storage;
|
||||||
|
|
||||||
public static Boolean Bungee;
|
public static Boolean Bungee;
|
||||||
public static String thisServer;
|
public static String thisServer;
|
||||||
|
@ -63,6 +61,8 @@ public class SelectConfig {
|
||||||
public static String UseItemWorldMode;
|
public static String UseItemWorldMode;
|
||||||
public static List<String> UseItemWorldList;
|
public static List<String> UseItemWorldList;
|
||||||
|
|
||||||
|
public static Boolean disableInfoBySneak;
|
||||||
|
|
||||||
public static Boolean UseItem_InventorySlot_FreeSlot;
|
public static Boolean UseItem_InventorySlot_FreeSlot;
|
||||||
public static Integer UseItem_InventorySlot;
|
public static Integer UseItem_InventorySlot;
|
||||||
public static Boolean UseItem_InventorySlotEnforce;
|
public static Boolean UseItem_InventorySlotEnforce;
|
||||||
|
@ -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");
|
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
||||||
HelpAlias = yamlConfiguration.getBoolean("Plugin.HelpAlias");
|
HelpAlias = yamlConfiguration.getBoolean("Plugin.HelpAlias");
|
||||||
language = yamlConfiguration.getString("Plugin.language");
|
language = yamlConfiguration.getString("Plugin.language");
|
||||||
Currency = yamlConfiguration.getString("Plugin.Currency");
|
Currency = yamlConfiguration.getString("Plugin.Currency");
|
||||||
DefaultGUI = yamlConfiguration.getString("Plugin.DefaultGUI");
|
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.ip = yamlConfiguration.getString("Storage.MySQL.IP");
|
||||||
MySQL.port = yamlConfiguration.getInt("Storage.MySQL.Port");
|
MySQL.port = yamlConfiguration.getInt("Storage.MySQL.Port");
|
||||||
|
@ -195,6 +189,9 @@ 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){
|
||||||
|
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
|
||||||
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|
|
@ -152,8 +152,8 @@ public class ConfigConverterUnderV5 {
|
||||||
set("Slots." + key + ".Enable", slotEnable, yamlConfiguration);
|
set("Slots." + key + ".Enable", slotEnable, yamlConfiguration);
|
||||||
set("Slots." + key + ".Function", function, yamlConfiguration);
|
set("Slots." + key + ".Function", function, yamlConfiguration);
|
||||||
set("Slots." + key + ".Permission.Required", permRequired, yamlConfiguration);
|
set("Slots." + key + ".Permission.Required", permRequired, yamlConfiguration);
|
||||||
set("Slots." + key + ".Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
|
set("Slots." + key + ".Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration);
|
||||||
set("Slots." + key + ".Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
|
set("Slots." + key + ".Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void set(String path, String value, YamlConfiguration config) {
|
private static void set(String path, String value, YamlConfiguration config) {
|
||||||
|
|
|
@ -33,15 +33,15 @@ public class CreateGUI {
|
||||||
set("Slots.SupportDiscord.Enable", true, yamlConfiguration);
|
set("Slots.SupportDiscord.Enable", true, yamlConfiguration);
|
||||||
set("Slots.SupportDiscord.Function", "SupportDiscord", yamlConfiguration);
|
set("Slots.SupportDiscord.Function", "SupportDiscord", yamlConfiguration);
|
||||||
set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration);
|
set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration);
|
||||||
set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
|
set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration);
|
||||||
set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
|
set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration);
|
||||||
|
|
||||||
set("Slots.UseItem.Slot", 6, yamlConfiguration);
|
set("Slots.UseItem.Slot", 6, yamlConfiguration);
|
||||||
set("Slots.UseItem.Enable", true, yamlConfiguration);
|
set("Slots.UseItem.Enable", true, yamlConfiguration);
|
||||||
set("Slots.UseItem.Function", "UseItem", yamlConfiguration);
|
set("Slots.UseItem.Function", "UseItem", yamlConfiguration);
|
||||||
set("Slots.UseItem.Permission.Required", false, yamlConfiguration);
|
set("Slots.UseItem.Permission.Required", false, yamlConfiguration);
|
||||||
set("Slots.UseItem.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration);
|
set("Slots.UseItem.Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration);
|
||||||
set("Slots.UseItem.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration);
|
set("Slots.UseItem.Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -109,13 +109,13 @@ 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.GUI_FillItem_Item));
|
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.guiFillItemItem));
|
||||||
} else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_")));
|
} else glass = new ItemStack(Material.valueOf(gui.guiFillItemItem.toUpperCase().replace(".", "_")));
|
||||||
ItemMeta itemMetaglass = glass.getItemMeta();
|
ItemMeta itemMetaglass = glass.getItemMeta();
|
||||||
itemMetaglass.setDisplayName(" ");
|
itemMetaglass.setDisplayName(" ");
|
||||||
glass.setItemMeta(itemMetaglass);
|
glass.setItemMeta(itemMetaglass);
|
||||||
glass.setAmount(1);
|
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);
|
inventory.setItem(i, glass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.jatitv.commandguiv2.Spigot.gui;
|
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.Listener.UseItem_Listener.Events;
|
||||||
import de.jatitv.commandguiv2.Spigot.Main;
|
import de.jatitv.commandguiv2.Spigot.Main;
|
||||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||||
|
@ -26,7 +26,7 @@ public class OpenGUI {
|
||||||
private static Plugin plugin = Main.plugin;
|
private static Plugin plugin = Main.plugin;
|
||||||
private static String prefix = Util.getPrefix();
|
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);
|
Gui gui = Main.guiHashMap.get(guiString);
|
||||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||||
switch (guiString) {
|
switch (guiString) {
|
||||||
|
@ -63,20 +63,26 @@ public class OpenGUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MCVersion.minecraft1_13) {
|
if (MCVersion.minecraft1_13) {
|
||||||
GUI_Listener.GUICode = "";
|
GUIListener.GUICode = "";
|
||||||
} else GUI_Listener.GUICode = "§6§8§9§r";
|
} else GUIListener.GUICode = "§6§8§9§r";
|
||||||
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||||
Inventory inventory;
|
Inventory inventory;
|
||||||
if (Main.PaPi) {
|
if (Main.PaPi) {
|
||||||
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name)));
|
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, player, GUIListener.GUICode + gui.guiName)));
|
||||||
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name)));
|
} 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);
|
GuiBuilder.fillItem(inventory, gui);
|
||||||
}
|
}
|
||||||
for (Slot slot : gui.slots) {
|
for (Slot slot : gui.slots) {
|
||||||
Function function = Main.functionHashMap.get(slot.function);
|
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 (slot.enable) {
|
||||||
if (function.empty) {
|
if (function.empty) {
|
||||||
ItemStack air = new ItemStack(Material.AIR);
|
ItemStack air = new ItemStack(Material.AIR);
|
||||||
|
@ -98,9 +104,9 @@ public class OpenGUI {
|
||||||
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 (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" +
|
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.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));
|
(slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name));
|
||||||
} else {
|
} else {
|
||||||
if (function.base64_Enable) {
|
if (function.base64_Enable) {
|
||||||
|
@ -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);
|
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");
|
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.GUI_Name)));
|
} else player.sendMessage(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) {
|
||||||
|
|
|
@ -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.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 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;
|
||||||
|
|
||||||
|
@ -16,8 +17,8 @@ import java.util.Objects;
|
||||||
|
|
||||||
public class Obj_Select {
|
public class Obj_Select {
|
||||||
public static void onSelect() {
|
public static void onSelect() {
|
||||||
onSelectGui();
|
|
||||||
onSelectFunction();
|
onSelectFunction();
|
||||||
|
onSelectGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onSelectGui() {
|
public static void onSelectGui() {
|
||||||
|
@ -29,9 +30,9 @@ public class Obj_Select {
|
||||||
for (File config_gui : fileArray) {
|
for (File config_gui : fileArray) {
|
||||||
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
|
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
|
||||||
if (sub.equals(".yml")) {
|
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);
|
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui);
|
||||||
String guiFileName = config_gui.getName().replace(".yml", "");
|
|
||||||
|
|
||||||
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
|
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
|
||||||
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
|
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
|
||||||
|
@ -53,25 +54,31 @@ public class Obj_Select {
|
||||||
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
|
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
|
||||||
|
|
||||||
ArrayList<Slot> slots = new ArrayList<>();
|
ArrayList<Slot> slots = new ArrayList<>();
|
||||||
for (String key : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
|
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
|
||||||
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + key + ".Slot") - 1;
|
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
|
||||||
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + key + ".Enable");
|
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
|
||||||
String function = yamlConfiguration_gui.getString("Slots." + key + ".Function");
|
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
|
||||||
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required");
|
Function functionCheck = Main.functionHashMap.get(function);
|
||||||
String permSee = yamlConfiguration_gui.getString("Slots." + key + ".Permission.See");
|
if (functionCheck == null) {
|
||||||
String permUse = yamlConfiguration_gui.getString("Slots." + key + ".Permission.Use");
|
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,
|
Slot slot = new Slot(slotNumber, enable, function, permRequired,
|
||||||
Objects.requireNonNull(permSee).replace("[guiname]", guiFileName).replace("[slot]", String.valueOf(slotNumber))
|
Objects.requireNonNull(permSee).replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
|
||||||
.replace("[slotname]", key), permUse);
|
.replace("[slotname]", slotKey.toLowerCase()),
|
||||||
|
Objects.requireNonNull(permUse).replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
|
||||||
|
.replace("[slotname]", slotKey.toLowerCase()));
|
||||||
slots.add(slot);
|
slots.add(slot);
|
||||||
}
|
}
|
||||||
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
|
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
|
||||||
config_gui.getName().replace(".yml", ""), commandAliasEnable, commandPermission, slots);
|
key, commandAliasEnable, commandPermission, slots);
|
||||||
|
|
||||||
Main.guiHashMap.put(guiFileName, gui);
|
Main.guiHashMap.put(key, gui);
|
||||||
CmdExecuter_GUITab.arg1.put(config_gui.getName()
|
CmdExecuter_GUITab.arg1.put(config_gui.getName()
|
||||||
.replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", ""));
|
.replace(".yml", ""), "commandgui.gui." + key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yamlConfiguration_gui.save(config_gui);
|
yamlConfiguration_gui.save(config_gui);
|
||||||
|
@ -92,6 +99,7 @@ public class Obj_Select {
|
||||||
if (sub.equals(".yml")) {
|
if (sub.equals(".yml")) {
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
String key = config.getName().replace(".yml", "");
|
||||||
Boolean empty = yamlConfiguration.getBoolean("Slots.Function.Item.Empty");
|
Boolean empty = yamlConfiguration.getBoolean("Slots.Function.Item.Empty");
|
||||||
Integer itemAmount = yamlConfiguration.getInt("Slots.Function.Item.Amount");
|
Integer itemAmount = yamlConfiguration.getInt("Slots.Function.Item.Amount");
|
||||||
Boolean playerHead_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Enable");
|
Boolean playerHead_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Enable");
|
||||||
|
@ -143,13 +151,13 @@ public class Obj_Select {
|
||||||
String pluginReloadCommand = yamlConfiguration.getString("Slots.Function.SetConfig.PluginReload.Command");
|
String pluginReloadCommand = yamlConfiguration.getString("Slots.Function.SetConfig.PluginReload.Command");
|
||||||
|
|
||||||
|
|
||||||
Function function = new Function(empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore,
|
Function function = new Function(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore,
|
||||||
customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, price, command_Enable, command_BungeeCommand, commandAsConsole, command,
|
customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, price, command_Enable, command_BungeeCommand, commandAsConsole, command,
|
||||||
serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, message,
|
serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, message,
|
||||||
setConfigEnable, configFilePath, configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft,
|
setConfigEnable, configFilePath, configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft,
|
||||||
configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight,
|
configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight,
|
||||||
configListValueRight, pluginReloadEnable, pluginReloadCommand);
|
configListValueRight, pluginReloadEnable, pluginReloadCommand);
|
||||||
Main.functionHashMap.put(config.getName().replace(".yml", ""), function);
|
Main.functionHashMap.put(key, function);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yamlConfiguration.save(config);
|
yamlConfiguration.save(config);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class Function {
|
public class Function {
|
||||||
|
|
||||||
|
public String key;
|
||||||
public Boolean empty;
|
public Boolean empty;
|
||||||
public Integer itemAmount;
|
public Integer itemAmount;
|
||||||
public Boolean playerHead_Enable;
|
public Boolean playerHead_Enable;
|
||||||
|
@ -54,7 +55,8 @@ public class Function {
|
||||||
public Boolean pluginReloadEnable;
|
public Boolean pluginReloadEnable;
|
||||||
public String pluginReloadCommand;
|
public String pluginReloadCommand;
|
||||||
|
|
||||||
public Function(Boolean empty,
|
public Function(String key,
|
||||||
|
Boolean empty,
|
||||||
Integer itemAmount,
|
Integer itemAmount,
|
||||||
Boolean playerHead_Enable,
|
Boolean playerHead_Enable,
|
||||||
Boolean base64Value_Enable,
|
Boolean base64Value_Enable,
|
||||||
|
@ -101,6 +103,7 @@ public class Function {
|
||||||
|
|
||||||
Boolean pluginReloadEnable,
|
Boolean pluginReloadEnable,
|
||||||
String pluginReloadCommand) {
|
String pluginReloadCommand) {
|
||||||
|
this.key = key;
|
||||||
this.empty = empty;
|
this.empty = empty;
|
||||||
this.itemAmount = itemAmount;
|
this.itemAmount = itemAmount;
|
||||||
this.playerHead_Enable = playerHead_Enable;
|
this.playerHead_Enable = playerHead_Enable;
|
||||||
|
@ -152,6 +155,5 @@ public class Function {
|
||||||
this.pluginReloadCommand = pluginReloadCommand;
|
this.pluginReloadCommand = pluginReloadCommand;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,28 +5,28 @@ import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Gui {
|
public class Gui {
|
||||||
public Boolean GUI_Enable;
|
public Boolean guiEnable;
|
||||||
public Integer GUI_Lines;
|
public Integer guiLines;
|
||||||
public String GUI_Name;
|
public String guiName;
|
||||||
public Boolean GUI_FillItem_Enable;
|
public Boolean guiFillItemEnable;
|
||||||
public String GUI_FillItem_Item;
|
public String guiFillItemItem;
|
||||||
|
|
||||||
|
|
||||||
public String Command_Command;
|
public String key;
|
||||||
public Boolean Command_Alias_Enable;
|
public Boolean commandAliasEnable;
|
||||||
public Boolean Command_Permission_Enable;
|
public Boolean commandPermissionEnable;
|
||||||
public ArrayList<Slot> slots;
|
public ArrayList<Slot> slots;
|
||||||
|
|
||||||
public Gui(Boolean GUI_Enable, Integer GUI_Lines, String GUI_Name, Boolean GUI_FillItem_Enable, String GUI_FillItem_Item,
|
public Gui(Boolean guiEnable, Integer guiLines, String guiName, Boolean guiFillitemEnable, String guiFillitemItem,
|
||||||
String Command_Command, Boolean Command_Alias_Enable, Boolean Command_Permission_Enable, ArrayList<Slot> slots){
|
String commandCommand, Boolean commandAliasEnable, Boolean commandPermissionEnable, ArrayList<Slot> slots){
|
||||||
this.GUI_Enable = GUI_Enable;
|
this.guiEnable = guiEnable;
|
||||||
this.GUI_Lines = GUI_Lines;
|
this.guiLines = guiLines;
|
||||||
this.GUI_Name = GUI_Name;
|
this.guiName = guiName;
|
||||||
this.GUI_FillItem_Enable = GUI_FillItem_Enable;
|
this.guiFillItemEnable = guiFillitemEnable;
|
||||||
this.GUI_FillItem_Item = GUI_FillItem_Item;
|
this.guiFillItemItem = guiFillitemItem;
|
||||||
this.Command_Command = Command_Command;
|
this.key = commandCommand;
|
||||||
this.Command_Alias_Enable = Command_Alias_Enable;
|
this.commandAliasEnable = commandAliasEnable;
|
||||||
this.Command_Permission_Enable = Command_Permission_Enable;
|
this.commandPermissionEnable = commandPermissionEnable;
|
||||||
this.slots = slots;
|
this.slots = slots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.jatitv.commandguiv2.Spigot.system;
|
package de.jatitv.commandguiv2.Spigot.system;
|
||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener;
|
import de.jatitv.commandguiv2.Spigot.Listener.GUIListener;
|
||||||
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events_from1_10;
|
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.EventsFrom110;
|
||||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
|
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
|
||||||
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;
|
||||||
|
@ -17,6 +17,9 @@ import de.jatitv.commandguiv2.Spigot.Main;
|
||||||
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
|
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
|
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.system.database.SQLITE;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
|
||||||
import 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;
|
||||||
|
@ -26,6 +29,7 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Load {
|
public class Load {
|
||||||
|
@ -42,7 +46,6 @@ public class Load {
|
||||||
|
|
||||||
send.console(prefix + " §8-------------------------------");
|
send.console(prefix + " §8-------------------------------");
|
||||||
|
|
||||||
|
|
||||||
if (!new File(Main.getPath(), "config.yml").exists()) {
|
if (!new File(Main.getPath(), "config.yml").exists()) {
|
||||||
try {
|
try {
|
||||||
CreateGUI.configCreate();
|
CreateGUI.configCreate();
|
||||||
|
@ -108,28 +111,9 @@ public class Load {
|
||||||
}
|
}
|
||||||
|
|
||||||
send.console(prefix + " §8-------------------------------");
|
send.console(prefix + " §8-------------------------------");
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
loadStorage(prefix);
|
||||||
MySQL.main();
|
send.console(prefix + " §8-------------------------------");
|
||||||
send.console(prefix + " §2Storage medium §6MySQL §2is used.");
|
|
||||||
try {
|
|
||||||
MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
|
||||||
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
|
||||||
" `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
|
||||||
" `Status` INT(1) NOT NULL DEFAULT '1'," +
|
|
||||||
" `Slot` INT(1) NULL DEFAULT NULL," +
|
|
||||||
" UNIQUE INDEX `UUID` (`UUID`)" +
|
|
||||||
")" +
|
|
||||||
"COLLATE='utf8mb4_general_ci'" +
|
|
||||||
"ENGINE=InnoDB" +
|
|
||||||
";");
|
|
||||||
MySQL.query("ALTER TABLE `gui-item` ADD COLUMN IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
send.console(prefix + " §2Storage medium §6YML §2is used.");
|
|
||||||
}
|
|
||||||
if (Main.PaPi) {
|
if (Main.PaPi) {
|
||||||
send.console(prefix + " §2PlaceholderAPI successfully connected!");
|
send.console(prefix + " §2PlaceholderAPI successfully connected!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,7 +121,7 @@ public class Load {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RegisterPermissions.onPermRegister();
|
Permissions.onPermRegister();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -157,13 +141,13 @@ public class Load {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new GUI_Listener(), plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(new GUIListener(), plugin);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new PluginEvent(), plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(new PluginEvent(), plugin);
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new Events(), Main.plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(new Events(), Main.plugin);
|
||||||
|
|
||||||
if (!MCVersion.minecraft1_8 && !MCVersion.minecraft1_9) {
|
if (!MCVersion.minecraft1_8 && !MCVersion.minecraft1_9) {
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new Events_from1_10(), plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
||||||
|
@ -171,4 +155,55 @@ public class Load {
|
||||||
Main.addonLoad();
|
Main.addonLoad();
|
||||||
T2CodeTemplate.onLoadFooter(prefix, long_);
|
T2CodeTemplate.onLoadFooter(prefix, long_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void loadStorage(String prefix) {
|
||||||
|
try {
|
||||||
|
SelectDatabase.setStorage(StorageType.valueOf(SelectConfig.storage));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
send.error(Main.plugin, "The storage medium " + SelectConfig.storage + " is not supported!");
|
||||||
|
send.error(Main.plugin, "Storage medium " + StorageType.SQLITE + " is used.");
|
||||||
|
SelectDatabase.setStorage(StorageType.SQLITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (SelectDatabase.getStorage()) {
|
||||||
|
case MYSQL:
|
||||||
|
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||||
|
MySQL.main();
|
||||||
|
try {
|
||||||
|
MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
||||||
|
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
||||||
|
" `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
||||||
|
" `Status` INT(1) NOT NULL DEFAULT '1'," +
|
||||||
|
" `Slot` INT(1) NULL DEFAULT NULL," +
|
||||||
|
" UNIQUE INDEX `UUID` (`UUID`)" +
|
||||||
|
")" +
|
||||||
|
"COLLATE='utf8mb4_general_ci'" +
|
||||||
|
"ENGINE=InnoDB" +
|
||||||
|
";");
|
||||||
|
MySQL.query("ALTER TABLE `gui-item` ADD COLUMN IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YML:
|
||||||
|
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case SQLITE:
|
||||||
|
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||||
|
try {
|
||||||
|
SQLITE.main();
|
||||||
|
SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
||||||
|
"UUID TEXT NOT NULL," +
|
||||||
|
"Name TEXT NOT NULL," +
|
||||||
|
"Status INTEGER NOT NULL DEFAULT 1," +
|
||||||
|
"Slot INTEGER," +
|
||||||
|
"PRIMARY KEY(UUID)" +
|
||||||
|
");");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ package de.jatitv.commandguiv2.Spigot.system;
|
||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.Main;
|
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.database.SelectDatabase;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
|
||||||
import de.jatitv.commandguiv2.Util;
|
import de.jatitv.commandguiv2.Util;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
@ -34,8 +36,13 @@ public class Metrics {
|
||||||
public static void Bstats() {
|
public static void Bstats() {
|
||||||
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
|
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
|
||||||
Metrics metrics = new Metrics(Main.plugin, pluginId);
|
Metrics metrics = new Metrics(Main.plugin, pluginId);
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("updatecheckonjoin", () -> String.valueOf(SelectConfig.UpdateCheckOnJoin)));
|
metrics.addCustomChart(new DrilldownPie("storage_type_mysql", () -> {
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("storage_type_mysql", () -> SelectConfig.Storage));
|
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||||
|
String storage = SelectDatabase.getStorage().toString();
|
||||||
|
Map<String, Integer> entry = new HashMap<>();
|
||||||
|
entry.put(storage, 1); map.put(storage, entry);
|
||||||
|
return map;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package de.jatitv.commandguiv2.Spigot.system;
|
||||||
|
|
||||||
|
import de.jatitv.commandguiv2.Spigot.Main;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||||
|
import net.t2code.lib.Spigot.Lib.register.Register;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class Permissions {
|
||||||
|
private static final Plugin plugin = Main.plugin;
|
||||||
|
|
||||||
|
public static final String key = "commandgui.";
|
||||||
|
public static final String command = key + "command";
|
||||||
|
public static final String info = key + "command.info";
|
||||||
|
public static final String bypass = key + "bypass";
|
||||||
|
public static final String useitemToggle = key + "useitem.toggle";
|
||||||
|
public static final String useitem = key + "useitem";
|
||||||
|
public static final String getGuiItemAtLogin = key + "get.guiitem.at.login";
|
||||||
|
public static final String updatemsg = key + "updatemsgupdatemsg";
|
||||||
|
|
||||||
|
public static final String player = key + "player";
|
||||||
|
public static final String admin = key + "admin";
|
||||||
|
|
||||||
|
public static final PermissionDefault op = PermissionDefault.OP;
|
||||||
|
public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
|
||||||
|
|
||||||
|
public static void onPermRegister() {
|
||||||
|
Register.permission(command, op, plugin);
|
||||||
|
Register.permissionDescription(command, "Required permission to open GUIs via command", plugin);
|
||||||
|
|
||||||
|
Register.permission(getGuiItemAtLogin, op, plugin);
|
||||||
|
Register.permissionDescription(getGuiItemAtLogin, "Only players with this permission will receive the GUI item", plugin);
|
||||||
|
|
||||||
|
Register.permission(useitem, op, plugin);
|
||||||
|
Register.permissionDescription(useitem, "Required permission to use the GUI Item", plugin);
|
||||||
|
|
||||||
|
Register.permission(useitemToggle, op, plugin);
|
||||||
|
Register.permissionDescription(useitemToggle, "Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)", plugin);
|
||||||
|
|
||||||
|
Register.permission(updatemsg, op, plugin);
|
||||||
|
Register.permissionDescription(updatemsg, "Players with this permission get the update message when joining if an update is available", plugin);
|
||||||
|
|
||||||
|
Register.permission(bypass, op, plugin);
|
||||||
|
Register.permissionDescription(bypass, "Bypass to open disabled GUIs", plugin);
|
||||||
|
|
||||||
|
Register.permission(info, notOp, plugin);
|
||||||
|
Register.permissionDescription(info, "Permission to view CommandGUI info", plugin);
|
||||||
|
|
||||||
|
Register.permission(player, op, command, true, plugin);
|
||||||
|
Register.permission(player, op, getGuiItemAtLogin, true, plugin);
|
||||||
|
Register.permission(player, op, useitem, true, plugin);
|
||||||
|
Register.permission(player, op, useitemToggle, true, plugin);
|
||||||
|
Register.permissionDescription(player, "All permissions from CommandGUI for Player", plugin);
|
||||||
|
|
||||||
|
Register.permission(admin, op, command, true, plugin);
|
||||||
|
Register.permission(admin, op, getGuiItemAtLogin, true, plugin);
|
||||||
|
Register.permission(admin, op, useitem, true, plugin);
|
||||||
|
Register.permission(admin, op, useitemToggle, true, plugin);
|
||||||
|
Register.permission(admin, op, updatemsg, true, plugin);
|
||||||
|
Register.permission(admin, op, bypass, true, plugin);
|
||||||
|
Register.permission(admin, op, info, true, plugin);
|
||||||
|
Register.permissionDescription(admin, "All permissions from CommandGUI", plugin);
|
||||||
|
|
||||||
|
|
||||||
|
for (Gui gui : Main.guiHashMap.values()) {
|
||||||
|
Register.permission("commandgui.command." + gui.key, op, plugin);
|
||||||
|
Register.permission(admin, op, "commandgui.command." + gui.key, true, plugin);
|
||||||
|
for (Slot slot : gui.slots) {
|
||||||
|
Register.permission(slot.permissionToUse, op, plugin);
|
||||||
|
Register.permission(admin, op, slot.permissionToUse, true, plugin);
|
||||||
|
Register.permission(slot.permissionToSee, op, plugin);
|
||||||
|
Register.permission(admin, op, slot.permissionToSee, true, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,26 +0,0 @@
|
||||||
package de.jatitv.commandguiv2.Spigot.system;
|
|
||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.Main;
|
|
||||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
|
||||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
|
||||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.permissions.Permission;
|
|
||||||
|
|
||||||
public class RegisterPermissions {
|
|
||||||
public static void onPermRegister() {
|
|
||||||
for (Gui gui : Main.guiHashMap.values()) {
|
|
||||||
if (Bukkit.getPluginManager().getPermission("commandgui.command." + gui.Command_Command) == null) {
|
|
||||||
Bukkit.getPluginManager().addPermission(new Permission("commandgui.command." + gui.Command_Command));
|
|
||||||
}
|
|
||||||
for (Slot slot : gui.slots) {
|
|
||||||
if (Bukkit.getPluginManager().getPermission(slot.permissionToUse) == null) {
|
|
||||||
Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToUse));
|
|
||||||
}
|
|
||||||
if (Bukkit.getPluginManager().getPermission(slot.permissionToSee) == null) {
|
|
||||||
Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToSee));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ import com.mojang.authlib.properties.Property;
|
||||||
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.Main;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||||
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
|
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||||
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;
|
||||||
|
@ -20,15 +20,16 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Give_UseItem {
|
public class UseItem {
|
||||||
|
|
||||||
|
|
||||||
public static void onGive(Player player) {
|
public static void giveUseItem(Player player) {
|
||||||
Integer slot;
|
Integer slot;
|
||||||
if (SelectConfig.UseItem_InventorySlotEnforce){
|
if (protection(player, false)) return;
|
||||||
|
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
||||||
slot = SelectConfig.UseItem_InventorySlot;
|
slot = SelectConfig.UseItem_InventorySlot;
|
||||||
} else {
|
} else {
|
||||||
if (Events.useItemSlotHashMap.get(player)== null) {
|
if (Events.useItemSlotHashMap.get(player) == null) {
|
||||||
slot = SelectConfig.UseItem_InventorySlot;
|
slot = SelectConfig.UseItem_InventorySlot;
|
||||||
} else {
|
} else {
|
||||||
slot = Events.useItemSlotHashMap.get(player);
|
slot = Events.useItemSlotHashMap.get(player);
|
||||||
|
@ -37,12 +38,13 @@ public class Give_UseItem {
|
||||||
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
|
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
|
||||||
player.getInventory().addItem(itemStack(player));
|
player.getInventory().addItem(itemStack(player));
|
||||||
} else {
|
} else {
|
||||||
send.debug(Main.plugin,"setUseItem: " + player.getName() + " Slot: "+ Integer.parseInt(String.valueOf(slot-1)));
|
send.debug(Main.plugin, "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1)));
|
||||||
player.getInventory().setItem(slot - 1, itemStack(player));
|
player.getInventory().setItem(slot - 1, itemStack(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onGiveADD(Player player) {
|
public static void addUseItem(Player player) {
|
||||||
|
if (protection(player, false)) return;
|
||||||
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
|
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
|
||||||
player.getInventory().addItem(itemStack(player));
|
player.getInventory().addItem(itemStack(player));
|
||||||
} else player.getInventory().addItem(itemStack(player));
|
} else player.getInventory().addItem(itemStack(player));
|
||||||
|
@ -96,4 +98,52 @@ public class Give_UseItem {
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean protection(Player player, Boolean interact) {
|
||||||
|
if (SelectConfig.UseItemGameModeProtection) {
|
||||||
|
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||||
|
if (interact) {
|
||||||
|
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||||
|
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||||
|
if (interact) {
|
||||||
|
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||||
|
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (SelectConfig.UseItemWorldProtection) {
|
||||||
|
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
|
||||||
|
if (interact) {
|
||||||
|
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||||
|
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
|
||||||
|
if (interact) {
|
||||||
|
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||||
|
} else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeItem(Player player) {
|
||||||
|
send.debug(Main.plugin, "World disabled: " + player.getName() + " " + player.getWorld().toString());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -35,9 +35,9 @@ public class MySQL {
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
ds = new HikariDataSource(config);
|
ds = new HikariDataSource(config);
|
||||||
send.console(Main.prefix + " §2MySQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
send.console(Main.prefix + " §2MYSQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
//Bukkit.getConsoleSender().sendMessage((System.currentTimeMillis() - long_) + "ms");
|
//Bukkit.getConsoleSender().sendMessage((System.currentTimeMillis() - long_) + "ms");
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package de.jatitv.commandguiv2.Spigot.system.database;
|
||||||
|
|
||||||
|
import de.jatitv.commandguiv2.Spigot.Main;
|
||||||
|
import de.jatitv.commandguiv2.Util;
|
||||||
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class SQLITE {
|
||||||
|
protected static String url;
|
||||||
|
private static Connection con;
|
||||||
|
|
||||||
|
public static void main() throws SQLException {
|
||||||
|
long long_ = System.currentTimeMillis();
|
||||||
|
File directory = new File(Main.getPath() + "/Storage");
|
||||||
|
if (!directory.exists()) {
|
||||||
|
directory.mkdir();
|
||||||
|
}
|
||||||
|
url = "jdbc:sqlite:" + Main.plugin.getDataFolder() + "/Storage/data.db";
|
||||||
|
con = DriverManager.getConnection(url);
|
||||||
|
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2SQLITE successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
|
DatabaseMetaData dbmd = con.getMetaData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void query(String query) {
|
||||||
|
|
||||||
|
send.debug(Main.plugin, query);
|
||||||
|
try {
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
stmt.execute(query);
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void query(ArrayList<String> queryList) {
|
||||||
|
try {
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
for (String query : queryList) {
|
||||||
|
send.debug(Main.plugin, query);
|
||||||
|
stmt.addBatch(query);
|
||||||
|
}
|
||||||
|
stmt.executeBatch();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashMap<String, ArrayList<String>> selectAll(String query) {
|
||||||
|
send.debug(Main.plugin, query);
|
||||||
|
HashMap<String, ArrayList<String>> Result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(query);
|
||||||
|
int columns = rs.getMetaData().getColumnCount();
|
||||||
|
while (rs.next()) {
|
||||||
|
ArrayList<String> columnList = new ArrayList<>();
|
||||||
|
for (int i = 1; i <= columns; i++) {
|
||||||
|
columnList.add(rs.getString(i));
|
||||||
|
}
|
||||||
|
Result.put(rs.getString(1), columnList);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String select(String query) {
|
||||||
|
send.debug(Main.plugin, query);
|
||||||
|
String Ausgabe = "";
|
||||||
|
try {
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(query);
|
||||||
|
while (rs.next()) {
|
||||||
|
Ausgabe = String.valueOf(rs.getString(1));
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
return Ausgabe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int count(String query) {
|
||||||
|
send.debug(Main.plugin, query);
|
||||||
|
int count = 0;
|
||||||
|
try {
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(query);
|
||||||
|
while (rs.next()) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<String> selectRow(String query) {
|
||||||
|
send.debug(Main.plugin, query);
|
||||||
|
ArrayList<String> Result = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(query);
|
||||||
|
int columns = rs.getMetaData().getColumnCount();
|
||||||
|
while (rs.next()) {
|
||||||
|
for (int i = 1; i <= columns; i++) {
|
||||||
|
Result.add(rs.getString(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close() throws SQLException {
|
||||||
|
if (con != null) con.close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package de.jatitv.commandguiv2.Spigot.system.database;
|
||||||
|
|
||||||
|
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
|
||||||
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SelectDatabase {
|
||||||
|
|
||||||
|
private static StorageType Storage;
|
||||||
|
|
||||||
|
public static StorageType getStorage() {
|
||||||
|
return Storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStorage(StorageType storage) {
|
||||||
|
Storage = storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void nameCheck(Player player) {
|
||||||
|
switch (Storage) {
|
||||||
|
case MYSQL:
|
||||||
|
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
|
||||||
|
break;
|
||||||
|
case YML:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SQLITE:
|
||||||
|
default:
|
||||||
|
SQLITE.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSlot(Player player, Integer slot) {
|
||||||
|
switch (Storage) {
|
||||||
|
case MYSQL:
|
||||||
|
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
|
+ "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';");
|
||||||
|
break;
|
||||||
|
case YML:
|
||||||
|
YML.setGuiitemSlot(player, slot);
|
||||||
|
break;
|
||||||
|
case SQLITE:
|
||||||
|
default:
|
||||||
|
SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
|
+ "','" + slot + "') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setItemStatusTrue(Player player) {
|
||||||
|
Events.useItemHashMap.replace(player, true);
|
||||||
|
switch (Storage) {
|
||||||
|
case MYSQL:
|
||||||
|
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
|
+ "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';");
|
||||||
|
break;
|
||||||
|
case YML:
|
||||||
|
YML.setGuiitemOn(player);
|
||||||
|
break;
|
||||||
|
case SQLITE:
|
||||||
|
default:
|
||||||
|
SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
|
+ "') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '1';");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setItemStatusFalse(Player player) {
|
||||||
|
Events.useItemHashMap.replace(player, false);
|
||||||
|
switch (Storage) {
|
||||||
|
case MYSQL:
|
||||||
|
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
|
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';");
|
||||||
|
break;
|
||||||
|
case YML:
|
||||||
|
YML.setGuiitemOff(player);
|
||||||
|
break;
|
||||||
|
case SQLITE:
|
||||||
|
default:
|
||||||
|
SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
|
+ "', '0') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '0';");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean selectItemStatus(Player player) {
|
||||||
|
switch (Storage) {
|
||||||
|
case MYSQL:
|
||||||
|
String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
|
||||||
|
if (result == null || result.equals("")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return result.equals("1");
|
||||||
|
case YML:
|
||||||
|
return YML.selectGuiitemOn(player);
|
||||||
|
case SQLITE:
|
||||||
|
default:
|
||||||
|
String result2 = SQLITE.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
|
||||||
|
if (result2 == null || result2.equals("")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return result2.equals("1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer selectSlot(Player player) {
|
||||||
|
switch (Storage) {
|
||||||
|
case MYSQL:
|
||||||
|
String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
|
||||||
|
if (result == null || result.equals("") || result.equals("null")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Integer.parseInt(result);
|
||||||
|
case YML:
|
||||||
|
return YML.selectSlot(player);
|
||||||
|
case SQLITE:
|
||||||
|
default:
|
||||||
|
String result2 = SQLITE.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
|
||||||
|
if (result2 == null || result2.equals("") || result2.equals("null")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Integer.parseInt(result2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,72 +0,0 @@
|
||||||
package de.jatitv.commandguiv2.Spigot.system.database;
|
|
||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
|
|
||||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class Select_Database {
|
|
||||||
|
|
||||||
public static void nameCheck(Player player) {
|
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
|
||||||
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSlot(Player player, Integer slot) {
|
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
|
||||||
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
|
||||||
+ "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';");
|
|
||||||
} else {
|
|
||||||
YML.setGuiitemSlot(player, slot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setItemStatusTrue(Player player) {
|
|
||||||
Events.useItemHashMap.replace(player, true);
|
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
|
||||||
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
|
||||||
+ "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';");
|
|
||||||
} else {
|
|
||||||
YML.setGuiitemOn(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setItemStatusFalse(Player player) {
|
|
||||||
Events.useItemHashMap.replace(player, false);
|
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
|
||||||
|
|
||||||
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
|
||||||
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';");
|
|
||||||
} else {
|
|
||||||
YML.setGuiitemOff(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean selectItemStatus(Player player) {
|
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
|
||||||
if (MySQL.count("SELECT * FROM `gui-item` WHERE BINARY UUID='" + player.getUniqueId() + "'") > 0) {
|
|
||||||
if (MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';").equals("1")) {
|
|
||||||
return true;
|
|
||||||
} else return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return YML.selectGuiitemOn(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer selectSlot(Player player) {
|
|
||||||
if (SelectConfig.Storage.equals("MYSQL")) {
|
|
||||||
if (MySQL.count("SELECT * FROM `gui-item` WHERE BINARY UUID='" + player.getUniqueId() + "'") > 0) {
|
|
||||||
if (MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';") != "null") {
|
|
||||||
return Integer.valueOf(MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"));
|
|
||||||
} else return null;
|
|
||||||
} else return null;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return YML.selectSlot(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package de.jatitv.commandguiv2.Spigot.system.database;
|
||||||
|
|
||||||
|
public enum StorageType {
|
||||||
|
MYSQL,
|
||||||
|
SQLITE,
|
||||||
|
YML
|
||||||
|
}
|
|
@ -8,7 +8,8 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.Help;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
|
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
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 net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -52,12 +53,12 @@ public class CGuiAPI {
|
||||||
|
|
||||||
public static void setPlayerItemEnable(Player player, Boolean value) {
|
public static void setPlayerItemEnable(Player player, Boolean value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
Select_Database.setItemStatusTrue(player);
|
SelectDatabase.setItemStatusTrue(player);
|
||||||
} else Select_Database.setItemStatusFalse(player);
|
} else SelectDatabase.setItemStatusFalse(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlayerItemSlot(Player player, Integer value) {
|
public static void setPlayerItemSlot(Player player, Integer value) {
|
||||||
Select_Database.setSlot(player, value);
|
SelectDatabase.setSlot(player, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openDefaultGUI(Player player) {
|
public static void openDefaultGUI(Player player) {
|
||||||
|
@ -73,26 +74,24 @@ public class CGuiAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPluginInfo(CommandSender sender) {
|
public static void sendPluginInfo(CommandSender sender) {
|
||||||
if (sender.hasPermission("commandgui.command.info")) {
|
if (sender.hasPermission(Permissions.info)) {
|
||||||
Commands.info(sender);
|
Commands.info(sender);
|
||||||
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
|
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
|
||||||
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.command.info"));
|
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.info));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createDefaultGUI(CommandSender sender) {
|
public static void createDefaultGUI(CommandSender sender) {
|
||||||
if (sender.hasPermission("commandgui.admin")) {
|
if (sender.hasPermission(Permissions.admin)) {
|
||||||
CreateGUI.configCreate();
|
CreateGUI.configCreate();
|
||||||
sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
|
sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
|
||||||
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
|
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
|
||||||
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
|
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(CommandSender sender) {
|
public static void reload(CommandSender sender) {
|
||||||
if (sender.hasPermission("commandgui.admin")) {
|
if (sender.hasPermission(Permissions.admin)) {
|
||||||
Commands.reload(sender);
|
Commands.reload(sender);
|
||||||
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
|
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
|
||||||
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
|
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,56 +19,54 @@ commands:
|
||||||
commandguihelp:
|
commandguihelp:
|
||||||
description: CommandGUI Help
|
description: CommandGUI Help
|
||||||
aliases: [cguihelp, guihelp]
|
aliases: [cguihelp, guihelp]
|
||||||
# commandguiadmin:
|
|
||||||
# aliases: [cguiadmin, cguia]
|
|
||||||
commandgui-item:
|
commandgui-item:
|
||||||
aliases: [gui-item]
|
aliases: [gui-item]
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
#permissions:
|
||||||
commandgui.admin:
|
# commandgui.admin:
|
||||||
description: All permissions from CommandGUI
|
# description: All permissions from CommandGUI
|
||||||
default: op
|
# default: op
|
||||||
children:
|
# children:
|
||||||
commandgui.updatemsg: true
|
# commandgui.command: true
|
||||||
commandgui.command: true
|
# commandgui.get.guiitem.at.login: true
|
||||||
commandgui.get.guiitem.at.login: true
|
# commandgui.useitem: true
|
||||||
commandgui.useitem: true
|
# commandgui.useitem.toggle: true
|
||||||
commandgui.useitem.toggle: true
|
# commandgui.updatemsg: true
|
||||||
commandgui.bypass: true
|
# commandgui.bypass: true
|
||||||
commandgui.command.info: true
|
# commandgui.command.info: true
|
||||||
commandgui.command.give: true
|
# commandgui.command.give: true
|
||||||
|
#
|
||||||
commandgui.player:
|
# commandgui.player:
|
||||||
description: All permissions from CommandGUI
|
# description: All permissions from CommandGUI
|
||||||
default: op
|
# default: op
|
||||||
children:
|
# children:
|
||||||
commandgui.command: true
|
# commandgui.command: true
|
||||||
commandgui.get.guiitem.at.login: true
|
# commandgui.get.guiitem.at.login: true
|
||||||
commandgui.useitem: true
|
# commandgui.useitem: true
|
||||||
commandgui.useitem.toggle: true
|
# commandgui.useitem.toggle: true
|
||||||
|
#
|
||||||
commandgui.updatemsg:
|
# commandgui.updatemsg:
|
||||||
description: Players with this permission get the update message when joining if an update is available
|
# description: Players with this permission get the update message when joining if an update is available
|
||||||
default: op
|
# default: op
|
||||||
commandgui.command:
|
# commandgui.command:
|
||||||
description: Required permission to open GUIs via command
|
# description: Required permission to open GUIs via command
|
||||||
default: op
|
# default: op
|
||||||
commandgui.get.guiitem.at.login:
|
# commandgui.get.guiitem.at.login:
|
||||||
description: Only players with this permission will receive the GUI item
|
# description: Only players with this permission will receive the GUI item
|
||||||
default: op
|
# default: op
|
||||||
commandgui.useitem:
|
# commandgui.useitem:
|
||||||
description: Required permission to use the GUI Item
|
# description: Required permission to use the GUI Item
|
||||||
default: op
|
# default: op
|
||||||
commandgui.useitem.toggle:
|
# commandgui.useitem.toggle:
|
||||||
description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)
|
# description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)
|
||||||
default: op
|
# default: op
|
||||||
commandgui.bypass:
|
# commandgui.bypass:
|
||||||
description: Bypass to open disabled GUIs
|
# description: Bypass to open disabled GUIs
|
||||||
default: op
|
# default: op
|
||||||
commandgui.command.info:
|
# commandgui.command.info:
|
||||||
description: Permission to view CommandGUI info
|
# description: Permission to view CommandGUI info
|
||||||
default: not op
|
# default: not op
|
||||||
commandgui.command.give:
|
# commandgui.command.give:
|
||||||
description: Kommend in V2.1.0
|
# description: Kommend in V2.1.0
|
||||||
default: op
|
# default: op
|
Loading…
Reference in New Issue