api changes & clean code

This commit is contained in:
JaTiTV 2022-04-22 19:05:34 +02:00
parent 35a9930017
commit f3feddd317
7 changed files with 25 additions and 32 deletions

View File

@ -69,7 +69,6 @@
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
@ -113,12 +112,6 @@
<artifactId>HikariCP</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
@ -129,5 +122,11 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.22</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -11,7 +11,7 @@ import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.RegisterPermissions;
import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
@ -85,7 +85,7 @@ public class Commands {
e.printStackTrace();
}
try {
RegisterPermissions.onPermRegister();
Permissions.onPermRegister();
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -29,11 +29,9 @@ public class SelectConfig {
public static Boolean HelpAlias;
public static String language;
public static String Currency;
public static List<String> mainCommands;
public static String storage;
public static Boolean Bungee;
public static String thisServer;

View File

@ -46,7 +46,6 @@ public class Load {
send.console(prefix + " §8-------------------------------");
if (!new File(Main.getPath(), "config.yml").exists()) {
try {
CreateGUI.configCreate();
@ -122,7 +121,7 @@ public class Load {
}
try {
RegisterPermissions.onPermRegister();
Permissions.onPermRegister();
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -7,7 +7,7 @@ import net.t2code.lib.Spigot.Lib.register.Register;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
public class RegisterPermissions {
public class Permissions {
private static final Plugin plugin = Main.plugin;
public static final String key = "commandgui.";

View File

@ -17,7 +17,7 @@ public class SelectDatabase {
}
public static void nameCheck(Player player) {
switch (Storage){
switch (Storage) {
case MYSQL:
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
break;
@ -26,13 +26,11 @@ public class SelectDatabase {
break;
case SQLITE:
default:
SQLITE.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
break;
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:
@ -90,7 +88,7 @@ public class SelectDatabase {
switch (Storage) {
case MYSQL:
String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
if(result == null || result.equals("")){
if (result == null || result.equals("")) {
return true;
}
return result.equals("1");
@ -99,7 +97,7 @@ public class SelectDatabase {
case SQLITE:
default:
String result2 = SQLITE.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
if(result2 == null || result2.equals("")){
if (result2 == null || result2.equals("")) {
return true;
}
return result2.equals("1");
@ -110,7 +108,7 @@ public class SelectDatabase {
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")){
if (result == null || result.equals("") || result.equals("null")) {
return null;
}
return Integer.parseInt(result);
@ -119,7 +117,7 @@ public class SelectDatabase {
case SQLITE:
default:
String result2 = SQLITE.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
if(result2 == null || result2.equals("") || result2.equals("null")){
if (result2 == null || result2.equals("") || result2.equals("null")) {
return null;
}
return Integer.parseInt(result2);

View File

@ -8,6 +8,7 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.Help;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.command.CommandSender;
@ -73,26 +74,24 @@ public class CGuiAPI {
}
public static void sendPluginInfo(CommandSender sender) {
if (sender.hasPermission("commandgui.command.info")) {
if (sender.hasPermission(Permissions.info)) {
Commands.info(sender);
} 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) {
if (sender.hasPermission("commandgui.admin")) {
if (sender.hasPermission(Permissions.admin)) {
CreateGUI.configCreate();
sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin));
}
public static void reload(CommandSender sender) {
if (sender.hasPermission("commandgui.admin")) {
if (sender.hasPermission(Permissions.admin)) {
Commands.reload(sender);
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin"));
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin));
}
}