mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
sql fixes & more
fixes slconfig sql error fixes nickclean npe fixes a few command inconsistensies
This commit is contained in:
parent
495133da1a
commit
6cd995ff52
@ -79,7 +79,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
|
||||
if (enchantment == null)
|
||||
{
|
||||
msg("Invalid enchantment. Please run /enchantments for a list of valid enchantments.");
|
||||
msg("Invalid enchantment. Please run /enchant list for a list of valid enchantments.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin name>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setscformat <format> | clearscformat> | oldtags | logstick | syncroles>")
|
||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin name>] <clearips | clearip <ip> | setscformat <format> | clearscformat> | syncroles>")
|
||||
public class Command_myadmin extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
@ -76,7 +76,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.staffAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true);
|
||||
FUtil.staffAction(sender.getName(), "Clearing " + target.getName() + "'s IPs", true);
|
||||
}
|
||||
|
||||
int counter = target.getIps().size() - 1;
|
||||
@ -203,7 +203,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> singleArguments = Arrays.asList("clearips", "setscformat");
|
||||
List<String> singleArguments = Arrays.asList("clearips", "setscformat");
|
||||
List<String> doubleArguments = Arrays.asList("clearip", "clearscformat", "syncroles");
|
||||
if (args.length == 1)
|
||||
{
|
||||
|
@ -72,76 +72,78 @@ public class Command_nickclean extends FreedomCommand
|
||||
final String nickName = plugin.esb.getNickname(playerName);
|
||||
StringBuilder newNick = new StringBuilder();
|
||||
boolean nickChanged = false;
|
||||
|
||||
if(nickName.contains("§x"))
|
||||
if (nickName != null)
|
||||
{
|
||||
// Detects colors that are similar to blocked codes.
|
||||
spliterator:
|
||||
for (String split : nickName.split("§x"))
|
||||
if (nickName.contains("§x"))
|
||||
{
|
||||
List<Color> colors = new ArrayList<>();
|
||||
String hexColorSub = null;
|
||||
if (split.length() >= 12 && split.contains("§"))
|
||||
// Detects colors that are similar to blocked codes.
|
||||
spliterator:
|
||||
for (String split : nickName.split("§x"))
|
||||
{
|
||||
hexColorSub = split.substring(0, 12);
|
||||
split = String.valueOf(split.charAt(12));
|
||||
String hexColorString = "#" + hexColorSub.replaceAll("§", "");
|
||||
java.awt.Color hexColor = java.awt.Color.decode(hexColorString);
|
||||
|
||||
// Get a range of nearby colors that are alike to the color blocked.
|
||||
Color colorFirst;
|
||||
Color colorSecond;
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed() + 20, 255), Math.min(hexColor.getGreen() + 20, 255), Math.min(hexColor.getBlue() + 20, 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed() - 20, 0), Math.max(hexColor.getGreen() - 20, 0), Math.max(hexColor.getBlue() - 20, 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed() + 20, 255), Math.min(hexColor.getGreen(), 255), Math.min(hexColor.getBlue(), 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed() - 20, 0), Math.max(hexColor.getGreen(), 0), Math.max(hexColor.getBlue(), 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed(), 255), Math.min(hexColor.getGreen() + 20, 255), Math.min(hexColor.getBlue(), 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed(), 0), Math.max(hexColor.getGreen() - 20, 0), Math.max(hexColor.getBlue(), 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed(), 255), Math.min(hexColor.getGreen(), 255), Math.min(hexColor.getBlue() + 20, 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed(), 0), Math.max(hexColor.getGreen(), 0), Math.max(hexColor.getBlue() - 20, 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
for (String colorCode : ConfigEntry.BLOCKED_CHATCODES.getString().split(","))
|
||||
List<Color> colors = new ArrayList<>();
|
||||
String hexColorSub = null;
|
||||
if (split.length() >= 12 && split.contains("§"))
|
||||
{
|
||||
// Makes sure that there's hex colors in the split.
|
||||
for (Color color : colors)
|
||||
hexColorSub = split.substring(0, 12);
|
||||
split = String.valueOf(split.charAt(12));
|
||||
String hexColorString = "#" + hexColorSub.replaceAll("§", "");
|
||||
java.awt.Color hexColor = java.awt.Color.decode(hexColorString);
|
||||
|
||||
// Get a range of nearby colors that are alike to the color blocked.
|
||||
Color colorFirst;
|
||||
Color colorSecond;
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed() + 20, 255), Math.min(hexColor.getGreen() + 20, 255), Math.min(hexColor.getBlue() + 20, 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed() - 20, 0), Math.max(hexColor.getGreen() - 20, 0), Math.max(hexColor.getBlue() - 20, 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed() + 20, 255), Math.min(hexColor.getGreen(), 255), Math.min(hexColor.getBlue(), 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed() - 20, 0), Math.max(hexColor.getGreen(), 0), Math.max(hexColor.getBlue(), 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed(), 255), Math.min(hexColor.getGreen() + 20, 255), Math.min(hexColor.getBlue(), 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed(), 0), Math.max(hexColor.getGreen() - 20, 0), Math.max(hexColor.getBlue(), 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
colorFirst = Color.fromRGB(Math.min(hexColor.getRed(), 255), Math.min(hexColor.getGreen(), 255), Math.min(hexColor.getBlue() + 20, 255));
|
||||
colorSecond = Color.fromRGB(Math.max(hexColor.getRed(), 0), Math.max(hexColor.getGreen(), 0), Math.max(hexColor.getBlue() - 20, 0));
|
||||
colors.addAll(FUtil.createColorGradient(colorFirst, colorSecond, 40));
|
||||
|
||||
for (String colorCode : ConfigEntry.BLOCKED_CHATCODES.getString().split(","))
|
||||
{
|
||||
if (colorCodes.get(colorCode) != null && FUtil.colorClose(color, colorCodes.get(colorCode), 40))
|
||||
// Makes sure that there's hex colors in the split.
|
||||
for (Color color : colors)
|
||||
{
|
||||
nickChanged = true;
|
||||
newNick.append(split);
|
||||
continue spliterator;
|
||||
if (colorCodes.get(colorCode) != null && FUtil.colorClose(color, colorCodes.get(colorCode), 40))
|
||||
{
|
||||
nickChanged = true;
|
||||
newNick.append(split);
|
||||
continue spliterator;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newNick.append("§x").append(hexColorSub).append(split);
|
||||
}
|
||||
newNick.append("§x").append(hexColorSub).append(split);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Falls back on old code if hex isn't used.
|
||||
final Pattern REGEX = Pattern.compile(FUtil.colorize(ChatColor.COLOR_CHAR + "[" + StringUtils.join(ConfigEntry.BLOCKED_CHATCODES.getString().split(","), "") + "]"), Pattern.CASE_INSENSITIVE);
|
||||
if (!nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
|
||||
else
|
||||
{
|
||||
final Matcher matcher = REGEX.matcher(nickName);
|
||||
if (matcher.find())
|
||||
// Falls back on old code if hex isn't used.
|
||||
final Pattern REGEX = Pattern.compile(FUtil.colorize(ChatColor.COLOR_CHAR + "[" + StringUtils.join(ConfigEntry.BLOCKED_CHATCODES.getString().split(","), "") + "]"), Pattern.CASE_INSENSITIVE);
|
||||
if (!nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
|
||||
{
|
||||
nickChanged = true;
|
||||
newNick.append(matcher.replaceAll(""));
|
||||
final Matcher matcher = REGEX.matcher(nickName);
|
||||
if (matcher.find())
|
||||
{
|
||||
nickChanged = true;
|
||||
newNick.append(matcher.replaceAll(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(nickChanged)
|
||||
if (nickChanged)
|
||||
{
|
||||
msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNick.toString() + ChatColor.RESET + "\".");
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class PlayerData
|
||||
.append("- Tag: ").append(FUtil.colorize(tag)).append(ChatColor.GRAY).append("\n")
|
||||
.append("- Ride Mode: ").append(rideMode).append("\n")
|
||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n")
|
||||
.append("- Reddit Username: ").append(redditUsername)
|
||||
.append("- Reddit Username: ").append(redditUsername).append("\n")
|
||||
.append("- Login Message: ").append(loginMessage);
|
||||
|
||||
return output.toString();
|
||||
|
@ -247,16 +247,16 @@ public class SQLite extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO staff VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO staff VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
statement.setString(1, staffMember.getName());
|
||||
statement.setString(2, FUtil.listToString(staffMember.getIps()));
|
||||
statement.setString(3, staffMember.getRank().toString());
|
||||
statement.setBoolean(4, staffMember.isActive());
|
||||
statement.setLong(5, staffMember.getLastLogin().getTime());
|
||||
statement.setBoolean(7, staffMember.getCommandSpy());
|
||||
statement.setBoolean(8, staffMember.getPotionSpy());
|
||||
statement.setString(9, staffMember.getAcFormat());
|
||||
statement.setString(10, staffMember.getPteroID());
|
||||
statement.setBoolean(6, staffMember.getCommandSpy());
|
||||
statement.setBoolean(7, staffMember.getPotionSpy());
|
||||
statement.setString(8, staffMember.getAcFormat());
|
||||
statement.setString(9, staffMember.getPteroID());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
@ -270,7 +270,7 @@ public class SQLite extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO players VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO players VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
statement.setString(1, player.getName());
|
||||
statement.setString(2, FUtil.listToString(player.getIps()));
|
||||
statement.setString(3, FUtil.listToString(player.getNotes()));
|
||||
@ -281,11 +281,11 @@ public class SQLite extends FreedomService
|
||||
statement.setBoolean(8, player.hasVerification());
|
||||
statement.setString(9, player.getRideMode());
|
||||
statement.setInt(10, player.getCoins());
|
||||
statement.setString(12, FUtil.listToString(player.getItems()));
|
||||
statement.setInt(13, player.getTotalVotes());
|
||||
statement.setBoolean(14, player.doesDisplayDiscord());
|
||||
statement.setString(15, player.getRedditUsername());
|
||||
statement.setString(16, player.getLoginMessage());
|
||||
statement.setString(11, FUtil.listToString(player.getItems()));
|
||||
statement.setInt(12, player.getTotalVotes());
|
||||
statement.setBoolean(13, player.doesDisplayDiscord());
|
||||
statement.setString(14, player.getRedditUsername());
|
||||
statement.setString(15, player.getLoginMessage());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
|
Loading…
Reference in New Issue
Block a user