File tree Expand file tree Collapse file tree 3 files changed +54
-5
lines changed
AdvancedCore/src/com/bencodez/advancedcore/api Expand file tree Collapse file tree 3 files changed +54
-5
lines changed Original file line number Diff line number Diff line change @@ -267,11 +267,14 @@ private String getUUIDLookup(String playerName) {
267267 }
268268
269269 if (plugin .getStorageType ().equals (UserStorage .MYSQL )) {
270- ConcurrentHashMap <UUID , String > namesMap = plugin .getMysql ().getRowsUUIDNameQuery ();
271- for (Entry <UUID , String > entry : namesMap .entrySet ()) {
272- if (entry .getValue ().equalsIgnoreCase (playerName )) {
273- return entry .getKey ().toString ();
274- }
270+ String name = plugin .getMysql ().getUUID (playerName );
271+ if (name != null ) {
272+ return name ;
273+ }
274+ } else if (plugin .getStorageType ().equals (UserStorage .SQLITE )) {
275+ String name = plugin .getSQLiteUserTable ().getUUID (playerName );
276+ if (name != null ) {
277+ return name ;
275278 }
276279 } else {
277280 for (String uuid : plugin .getUserManager ().getAllUUIDs ()) {
Original file line number Diff line number Diff line change @@ -351,6 +351,29 @@ public Set<String> getNames() {
351351 }
352352 return names ;
353353 }
354+
355+ public String getUUID (String playerName ) {
356+ String query = "SELECT uuid FROM " + getName () + " WHERE " + "PlayerName" + "='" + playerName + "';" ;
357+ try (Connection conn = mysql .getConnectionManager ().getConnection ();
358+ PreparedStatement sql = conn .prepareStatement (query )) {
359+ ResultSet rs = sql .executeQuery ();
360+ /*
361+ * Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
362+ */
363+ if (rs .next ()) {
364+ String uuid = rs .getString ("uuid" );
365+ if (uuid != null && !uuid .isEmpty ()) {
366+ rs .close ();
367+ return uuid ;
368+ }
369+ }
370+ rs .close ();
371+ } catch (SQLException e ) {
372+ e .printStackTrace ();
373+ } catch (ArrayIndexOutOfBoundsException e ) {
374+ }
375+ return null ;
376+ }
354377
355378 public ConcurrentHashMap <UUID , String > getRowsUUIDNameQuery () {
356379 ConcurrentHashMap <UUID , String > uuidNames = new ConcurrentHashMap <UUID , String >();
Original file line number Diff line number Diff line change @@ -352,6 +352,29 @@ public List<Column> getRowsNames() {
352352 return result ;
353353 }
354354
355+ public String getUUID (String playerName ) {
356+ String query = "SELECT uuid FROM " + getName () + " WHERE " + "PlayerName" + "='" + playerName + "';" ;
357+
358+ try (PreparedStatement sql = sqLite .getSQLConnection ().prepareStatement (query )) {
359+ ResultSet rs = sql .executeQuery ();
360+ /*
361+ * Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
362+ */
363+ if (rs .next ()) {
364+ String uuid = rs .getString ("uuid" );
365+ if (uuid != null && !uuid .isEmpty ()) {
366+ rs .close ();
367+ return uuid ;
368+ }
369+ }
370+ rs .close ();
371+ } catch (SQLException e ) {
372+ e .printStackTrace ();
373+ } catch (ArrayIndexOutOfBoundsException e ) {
374+ }
375+ return null ;
376+ }
377+
355378 public ArrayList <String > getTableColumns () {
356379 ArrayList <String > columns = new ArrayList <String >();
357380 String query = "SELECT * FROM " + getName ();
You can’t perform that action at this time.
0 commit comments