From f5f11fe5ab8c820fc6e466d4e80e07d5f3bf2877 Mon Sep 17 00:00:00 2001 From: Cow Date: Sun, 6 Feb 2022 15:42:47 -0800 Subject: [PATCH] cap sensitivie --- .../io/github/punishmentsx/commands/BaseCommand.java | 1 - .../io/github/punishmentsx/database/mongo/Mongo.java | 4 ++-- .../io/github/punishmentsx/database/sequel/SQL.java | 4 ++-- .../io/github/punishmentsx/utils/PlayerUtil.java | 12 ++---------- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/github/punishmentsx/commands/BaseCommand.java b/src/main/java/io/github/punishmentsx/commands/BaseCommand.java index da5ecd3..e16a468 100644 --- a/src/main/java/io/github/punishmentsx/commands/BaseCommand.java +++ b/src/main/java/io/github/punishmentsx/commands/BaseCommand.java @@ -42,7 +42,6 @@ public Profile getProfile(CommandSender sender, PunishmentsX plugin, String play if (targetProfile == null) { sender.sendMessage("Player has never logged on the server!"); - sender.sendMessage("Names are case-sensitive for offline players!"); return null; } diff --git a/src/main/java/io/github/punishmentsx/database/mongo/Mongo.java b/src/main/java/io/github/punishmentsx/database/mongo/Mongo.java index 11236d8..5c51e16 100644 --- a/src/main/java/io/github/punishmentsx/database/mongo/Mongo.java +++ b/src/main/java/io/github/punishmentsx/database/mongo/Mongo.java @@ -48,7 +48,7 @@ public Type type() { } public Profile loadProfile(boolean async, String name, boolean store, MongoDeserializedResult mdr) { - getDocument(false, "profiles", "name", name, document -> { + getDocument(false, "profiles", "name", name.toLowerCase(), document -> { if(document != null) { UUID uuid = (UUID) document.get("_id"); Profile profile = new Profile(plugin, uuid); @@ -94,7 +94,7 @@ public Profile loadProfile(boolean async, UUID uuid, boolean store, MongoDeseria public void saveProfile(boolean async, Profile profile) { Map map = new HashMap<>(); - map.put("name", profile.getName()); + map.put("name", profile.getName().toLowerCase()); map.put("current_ip", profile.getCurrentIp()); map.put("ip_history", profile.getIpHistory()); map.put("punishments", profile.getPunishments()); diff --git a/src/main/java/io/github/punishmentsx/database/sequel/SQL.java b/src/main/java/io/github/punishmentsx/database/sequel/SQL.java index 03eb4e4..550b98a 100644 --- a/src/main/java/io/github/punishmentsx/database/sequel/SQL.java +++ b/src/main/java/io/github/punishmentsx/database/sequel/SQL.java @@ -36,7 +36,7 @@ public Type type() { public Profile loadProfile(boolean async, String name, boolean store, MongoDeserializedResult mdr) { try { PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM profiles WHERE name = ?"); - ps.setString(1, name); + ps.setString(1, name.toLowerCase()); ResultSet rs = ps.executeQuery(); if (plugin.getStorage().type() == Database.Type.MySQL) { @@ -146,7 +146,7 @@ public void saveProfile(boolean async, Profile profile) { ps.setString(1, profile.getUuid().toString()); ps.setString(2, ipHistoryString); ps.setString(3, punishmentsString); - ps.setString(4, profile.getName()); + ps.setString(4, profile.getName().toLowerCase()); ps.setString(5, profile.getCurrentIp()); ps.executeUpdate(); } catch (SQLException e) { diff --git a/src/main/java/io/github/punishmentsx/utils/PlayerUtil.java b/src/main/java/io/github/punishmentsx/utils/PlayerUtil.java index 71b8244..8a5f06a 100644 --- a/src/main/java/io/github/punishmentsx/utils/PlayerUtil.java +++ b/src/main/java/io/github/punishmentsx/utils/PlayerUtil.java @@ -15,11 +15,7 @@ public static Profile findPlayer(PunishmentsX plugin, String target) { if (targetPlayer == null) { targetProfile = plugin.getProfileManager().find(target, false); } else { - try { - targetProfile = plugin.getProfileManager().get(targetPlayer.getUniqueId()); - } catch (Exception e) { - return null; - } + targetProfile = plugin.getProfileManager().get(targetPlayer.getUniqueId()); } return targetProfile; @@ -32,11 +28,7 @@ public static Profile findPlayer(PunishmentsX plugin, UUID uuid) { if (targetPlayer == null) { targetProfile = plugin.getProfileManager().find(uuid, false); } else { - try { - targetProfile = plugin.getProfileManager().get(targetPlayer.getUniqueId()); - } catch (Exception e) { - return null; - } + targetProfile = plugin.getProfileManager().get(targetPlayer.getUniqueId()); } return targetProfile;