From aa4b8832f1d5dfdbdba6a58e8ba07d987739b516 Mon Sep 17 00:00:00 2001 From: A5H73Y Date: Tue, 4 Jun 2024 18:02:20 +0100 Subject: [PATCH] Fixed non-synchronized placeholders --- README.md | 3 +-- .../io/github/a5h73y/parkour/ParkourPlaceholders.java | 4 ++-- .../github/a5h73y/parkour/database/DatabaseManager.java | 9 +++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bfd8feb4..573c5bfc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ ![Parkour Logo](https://user-images.githubusercontent.com/6440871/208645721-b047416c-1ca3-471d-b146-6af9424ce639.png) [![discord server](https://img.shields.io/discord/328154925949517824.svg)](https://discord.gg/h9d2fSd) -[![travis-ci](https://travis-ci.org/A5H73Y/Parkour.svg?branch=master)](https://travis-ci.org/A5H73Y/Parkour/branches) -[![license: MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://tldrlegal.com/license/mit-license) [![releases](https://img.shields.io/github/v/release/A5H73Y/Parkour.svg?label=github%20release)](https://github.com/A5H73Y/Parkour/releases/latest) +[![license: MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://tldrlegal.com/license/mit-license) Parkour is the original, most powerful Parkour based plugin available! First released in November 2012, and has been updated since. Parkour is now open source, allowing you to contribute ideas and enhancements, or create your own spin on the plugin.

diff --git a/src/main/java/io/github/a5h73y/parkour/ParkourPlaceholders.java b/src/main/java/io/github/a5h73y/parkour/ParkourPlaceholders.java index d073e9fe..cfe62817 100644 --- a/src/main/java/io/github/a5h73y/parkour/ParkourPlaceholders.java +++ b/src/main/java/io/github/a5h73y/parkour/ParkourPlaceholders.java @@ -100,8 +100,8 @@ public boolean persist() { } @Override - public String onRequest(final OfflinePlayer offlinePlayer, - final @NotNull String placeholder) { + public synchronized String onRequest(final OfflinePlayer offlinePlayer, + final @NotNull String placeholder) { return retrieveValue(offlinePlayer, placeholder.toLowerCase(), placeholder.toLowerCase().split("_")); } diff --git a/src/main/java/io/github/a5h73y/parkour/database/DatabaseManager.java b/src/main/java/io/github/a5h73y/parkour/database/DatabaseManager.java index 12229e12..ed206226 100644 --- a/src/main/java/io/github/a5h73y/parkour/database/DatabaseManager.java +++ b/src/main/java/io/github/a5h73y/parkour/database/DatabaseManager.java @@ -853,12 +853,9 @@ private int calculateResultsLimit(int limit) { } private List getCourseCache(String courseName) { - if (!resultsCache.containsKey(courseName.toLowerCase())) { - resultsCache.put(courseName.toLowerCase(), - getTopCourseResults(courseName, getConfig().getMaximumCoursesCached())); - } - - return resultsCache.get(courseName.toLowerCase()); + String courseKey = courseName.toLowerCase(); + return resultsCache.computeIfAbsent(courseKey, + key -> getTopCourseResults(key, getConfig().getMaximumCoursesCached())); } /**