A few more

This commit is contained in:
Telesphoreo 2022-04-09 00:08:18 -05:00
parent e35d70bc3c
commit d55eaf0d3d
3 changed files with 33 additions and 18 deletions

View file

@ -118,7 +118,8 @@ public class Plex extends JavaPlugin
{ {
PlexUtils.testConnections(); PlexUtils.testConnections();
PlexLog.log("Connected to " + storageType.name().toUpperCase()); PlexLog.log("Connected to " + storageType.name().toUpperCase());
} catch (Exception e) }
catch (Exception e)
{ {
PlexLog.error("Failed to connect to " + storageType.name().toUpperCase()); PlexLog.error("Failed to connect to " + storageType.name().toUpperCase());
e.printStackTrace(); e.printStackTrace();
@ -135,7 +136,8 @@ public class Plex extends JavaPlugin
{ {
redisConnection.getJedis(); redisConnection.getJedis();
PlexLog.log("Connected to Redis!"); PlexLog.log("Connected to Redis!");
} else }
else
{ {
PlexLog.log("Redis is disabled in the configuration file, not connecting."); PlexLog.log("Redis is disabled in the configuration file, not connecting.");
} }
@ -143,7 +145,8 @@ public class Plex extends JavaPlugin
if (storageType == StorageType.MONGODB) if (storageType == StorageType.MONGODB)
{ {
mongoPlayerData = new MongoPlayerData(); mongoPlayerData = new MongoPlayerData();
} else }
else
{ {
sqlPlayerData = new SQLPlayerData(); sqlPlayerData = new SQLPlayerData();
sqlPunishment = new SQLPunishment(); sqlPunishment = new SQLPunishment();
@ -191,7 +194,8 @@ public class Plex extends JavaPlugin
if (mongoPlayerData != null) //back to mongo checking if (mongoPlayerData != null) //back to mongo checking
{ {
mongoPlayerData.update(plexPlayer); //update the player's document mongoPlayerData.update(plexPlayer); //update the player's document
} else if (sqlPlayerData != null) //sql checking }
else if (sqlPlayerData != null) //sql checking
{ {
sqlPlayerData.update(plexPlayer); sqlPlayerData.update(plexPlayer);
} }
@ -254,7 +258,8 @@ public class Plex extends JavaPlugin
author = props.getProperty("buildAuthor", "unknown"); author = props.getProperty("buildAuthor", "unknown");
date = props.getProperty("buildDate", "unknown"); date = props.getProperty("buildDate", "unknown");
head = props.getProperty("buildHead", "unknown"); head = props.getProperty("buildHead", "unknown");
} catch (Exception ex) }
catch (Exception ex)
{ {
PlexLog.error("Could not load build properties! Did you compile with NetBeans/Maven?"); PlexLog.error("Could not load build properties! Did you compile with NetBeans/Maven?");
} }

View file

@ -125,7 +125,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
{ {
send(sender, messageComponent("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMessage()))); send(sender, messageComponent("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMessage())));
return true; return true;
} else }
else
{ {
if (getLevel().isAtLeast(Rank.ADMIN) && !plexPlayer.isAdminActive()) if (getLevel().isAtLeast(Rank.ADMIN) && !plexPlayer.isAdminActive())
{ {
@ -133,14 +134,16 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
return true; return true;
} }
} }
} else if (plugin.getSystem().equalsIgnoreCase("permissions")) }
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (!player.hasPermission(perms.permission())) if (!player.hasPermission(perms.permission()))
{ {
send(sender, messageComponent("noPermissionNode", perms.permission())); send(sender, messageComponent("noPermissionNode", perms.permission()));
return true; return true;
} }
} else }
else
{ {
PlexLog.error("Neither permissions or ranks were selected to be used in the configuration file!"); PlexLog.error("Neither permissions or ranks were selected to be used in the configuration file!");
send(sender, "There is a server misconfiguration. Please alert a developer or the owner"); send(sender, "There is a server misconfiguration. Please alert a developer or the owner");
@ -149,12 +152,13 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
try try
{ {
Component component = this.execute(sender, isConsole(sender) ? null : (Player) sender, args); Component component = this.execute(sender, isConsole(sender) ? null : (Player)sender, args);
if (component != null) if (component != null)
{ {
send(sender, component); send(sender, component);
} }
} catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex) }
catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
{ {
send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage())); send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage()));
} }
@ -178,7 +182,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
return true; return true;
} }
} }
} else if (params.aliases().split(",").length < 1) }
else if (params.aliases().split(",").length < 1)
{ {
return getName().equalsIgnoreCase(label); return getName().equalsIgnoreCase(label);
} }
@ -232,7 +237,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
{ {
if (!isConsole(sender)) if (!isConsole(sender))
{ {
return checkRank((Player) sender, rank, permission); return checkRank((Player)sender, rank, permission);
} }
return true; return true;
} }
@ -263,7 +268,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
{ {
throw new CommandFailException(PlexUtils.messageString("noPermissionRank", ChatColor.stripColor(rank.getLoginMessage()))); throw new CommandFailException(PlexUtils.messageString("noPermissionRank", ChatColor.stripColor(rank.getLoginMessage())));
} }
} else if (plugin.getSystem().equalsIgnoreCase("permissions")) }
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (!player.hasPermission(permission)) if (!player.hasPermission(permission))
{ {
@ -283,7 +289,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
if (plugin.getSystem().equalsIgnoreCase("ranks")) if (plugin.getSystem().equalsIgnoreCase("ranks"))
{ {
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank); return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
} else if (plugin.getSystem().equalsIgnoreCase("permissions")) }
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
return player.hasPermission(permission); return player.hasPermission(permission);
} }
@ -303,7 +310,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
{ {
if (!isConsole(sender)) if (!isConsole(sender))
{ {
return checkTab((Player) sender, rank, permission); return checkTab((Player)sender, rank, permission);
} }
return true; return true;
} }
@ -323,7 +330,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
if (plugin.getSystem().equalsIgnoreCase("ranks")) if (plugin.getSystem().equalsIgnoreCase("ranks"))
{ {
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank); return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
} else if (plugin.getSystem().equalsIgnoreCase("permissions")) }
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
return player.hasPermission(permission); return player.hasPermission(permission);
} }

View file

@ -20,8 +20,10 @@ public class AdminListener extends PlexListener
PlexPlayer target = event.getPlexPlayer(); PlexPlayer target = event.getPlexPlayer();
if (!target.getRank().isEmpty()) if (!target.getRank().isEmpty())
{ {
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable())); PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
} else { }
else
{
target.setRank(Rank.ADMIN.name()); target.setRank(Rank.ADMIN.name());
PlexUtils.broadcast(messageComponent("newAdminAdded", userSender, target.getName())); PlexUtils.broadcast(messageComponent("newAdminAdded", userSender, target.getName()));
} }