diff --git a/pom.xml b/pom.xml
index 196eea2a..1f622b1e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,35 +10,14 @@
ScoreboardStats
2013
Show the Scoreboard with many custom variables
- 0.10.1
- http://dev.bukkit.org/bukkit-plugins/scoreboardstats
+ 0.10.3
+ https://dev.bukkit.org/bukkit-plugins/scoreboardstats
UTF-8
1.7.0
-
- ${basedir}/target
-
- GitHub
- https://github.com/games647/ScoreboardStats/issues
-
-
-
- https://github.com/games647/ScoreboardStats
- scm:git:git://github.com/games647/ScoreboardStats.git
- scm:git:ssh://git@github.com:games647/ScoreboardStats.git
-
-
-
-
- The MIT License
- http://opensource.org/licenses/MIT
- repo
-
-
-
install
@@ -52,17 +31,6 @@
1.8
- true
- true
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.0.2
-
- ${outputDir}
@@ -100,14 +68,6 @@
true
-
-
-
- ${basedir}
-
- LICENSE
-
-
@@ -121,7 +81,7 @@
md_5-releases
- http://repo.md-5.net/content/groups/public/
+ https://repo.md-5.net/content/groups/public/
@@ -174,7 +134,7 @@
bintray-tastybento-maven-repo
bintray
- http://dl.bintray.com/tastybento/maven-repo
+ https://dl.bintray.com/tastybento/maven-repo
diff --git a/src/main/java/com/github/games647/scoreboardstats/RefreshTask.java b/src/main/java/com/github/games647/scoreboardstats/RefreshTask.java
index e1945b73..d29d47eb 100644
--- a/src/main/java/com/github/games647/scoreboardstats/RefreshTask.java
+++ b/src/main/java/com/github/games647/scoreboardstats/RefreshTask.java
@@ -39,16 +39,16 @@ public void run() {
int remainingUpdates = getNextUpdates();
for (Map.Entry entry : queue.entrySet()) {
Player player = entry.getKey();
- MutableInt remanigTicks = entry.getValue();
- if (remanigTicks.intValue() == 0) {
+ MutableInt remainingTicks = entry.getValue();
+ if (remainingTicks.intValue() == 0) {
if (remainingUpdates != 0) {
//Smoother refreshing; limit the updates
plugin.getScoreboardManager().onUpdate(player);
- remanigTicks.setValue(20 * Settings.getInterval());
+ remainingTicks.setValue(20 * Settings.getInterval());
remainingUpdates--;
}
} else {
- remanigTicks.decrement();
+ remainingTicks.decrement();
}
}
diff --git a/src/main/java/com/github/games647/scoreboardstats/commands/SidebarCommands.java b/src/main/java/com/github/games647/scoreboardstats/commands/SidebarCommands.java
index 9cdb052f..b6b3f70c 100644
--- a/src/main/java/com/github/games647/scoreboardstats/commands/SidebarCommands.java
+++ b/src/main/java/com/github/games647/scoreboardstats/commands/SidebarCommands.java
@@ -6,7 +6,6 @@
import com.google.common.collect.Maps;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -78,7 +77,7 @@ public List onTabComplete(CommandSender sender, Command command, String
suggestion = commandHandler.onTabComplete(sender, subCommand, Arrays.copyOfRange(args, 1, args.length));
if (suggestion != null) {
//Prevent NPEs and the usage of this method in nearly every handler
- Collections.sort(suggestion, String.CASE_INSENSITIVE_ORDER);
+ suggestion.sort(String.CASE_INSENSITIVE_ORDER);
}
return suggestion;
diff --git a/src/main/java/com/github/games647/scoreboardstats/pvpstats/Database.java b/src/main/java/com/github/games647/scoreboardstats/pvpstats/Database.java
index 3284f711..8b971dbb 100644
--- a/src/main/java/com/github/games647/scoreboardstats/pvpstats/Database.java
+++ b/src/main/java/com/github/games647/scoreboardstats/pvpstats/Database.java
@@ -6,7 +6,6 @@
import com.github.games647.scoreboardstats.config.Settings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.zaxxer.hikari.HikariDataSource;
import java.sql.Connection;
@@ -21,10 +20,7 @@
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CancellationException;
-import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.stream.Collectors;
@@ -42,8 +38,6 @@ public class Database {
private final ScoreboardStats plugin;
- private final ScheduledExecutorService executor;
-
private final Map toplist = Maps.newHashMapWithExpectedSize(Settings.getTopitems());
private final DatabaseConfiguration dbConfig;
@@ -52,11 +46,6 @@ public class Database {
public Database(ScoreboardStats plugin) {
this.plugin = plugin;
this.dbConfig = new DatabaseConfiguration(plugin);
-
- //SQL transactions are mainly blocking so there is no need to update them smooth
- executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder()
- //Give the thread a name so we can find them
- .setNameFormat(plugin.getName() + "-Database").build());
}
/**
@@ -84,7 +73,8 @@ public PlayerStats getCachedStats(Player request) {
*/
public void loadAccountAsync(Player player) {
if (getCachedStats(player) == null && dataSource != null) {
- executor.execute(new StatsLoader(plugin, dbConfig.isUuidUse(), player, this));
+ Runnable statsLoader = new StatsLoader(plugin, dbConfig.isUuidUse(), player, this);
+ Bukkit.getScheduler().runTaskAsynchronously(plugin, statsLoader);
}
}
@@ -172,7 +162,7 @@ public PlayerStats loadAccount(Player player) {
* @param stats PlayerStats data
*/
public void saveAsync(PlayerStats stats) {
- executor.submit(() -> save(Lists.newArrayList(stats)));
+ Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> save(Lists.newArrayList(stats)));
}
/**
@@ -291,15 +281,10 @@ public void saveAll() {
save(toSave);
}
- executor.shutdown();
-
- executor.awaitTermination(15, TimeUnit.MINUTES);
- } catch (InterruptedException ex) {
- plugin.getLogger().log(Level.SEVERE, "Couldn't save the stats to the database", ex);
+ dataSource.close();
} finally {
//Make rally sure we remove all even on error
BackwardsCompatibleUtil.getOnlinePlayers()
- .stream()
.forEach(player -> player.removeMetadata(METAKEY, plugin));
}
}
@@ -340,9 +325,8 @@ public void setupDatabase() {
close(conn);
}
- executor.scheduleWithFixedDelay(this::updateTopList, 0, 5, TimeUnit.MINUTES);
-
- executor.scheduleWithFixedDelay(() -> {
+ Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateTopList, 20 * 60 * 5, 0);
+ Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
if (dataSource == null) {
return;
}
@@ -367,7 +351,7 @@ public void setupDatabase() {
} catch (Exception ex) {
plugin.getLogger().log(Level.SEVERE, null, ex);
}
- }, 0, 1, TimeUnit.MINUTES);
+ }, 20 * 60, 0);
registerEvents();
}
diff --git a/src/main/java/com/github/games647/scoreboardstats/scoreboard/bukkit/BukkitScoreboardManager.java b/src/main/java/com/github/games647/scoreboardstats/scoreboard/bukkit/BukkitScoreboardManager.java
index 9ef3badf..fb481e66 100644
--- a/src/main/java/com/github/games647/scoreboardstats/scoreboard/bukkit/BukkitScoreboardManager.java
+++ b/src/main/java/com/github/games647/scoreboardstats/scoreboard/bukkit/BukkitScoreboardManager.java
@@ -128,7 +128,7 @@ public void createTopListScoreboard(Player player) {
objective.setDisplayName(Settings.getTempTitle());
//Colorize and send all elements
- plugin.getStatsDatabase().getTop().stream().forEach((entry) -> {
+ plugin.getStatsDatabase().getTop().forEach((entry) -> {
String scoreName = stripLength(Settings.getTempColor() + entry.getKey());
sendScore(objective, scoreName, entry.getValue(), true);
});
diff --git a/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketListener.java b/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketListener.java
index f84e23a8..287b1a1d 100644
--- a/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketListener.java
+++ b/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketListener.java
@@ -35,7 +35,7 @@ public class PacketListener extends PacketAdapter {
/**
* Creates a new packet listener
*
- * @param plugin plugin for registration into ProtcolLib
+ * @param plugin plugin for registration into ProtocolLib
* @param manager packet manager instance
*/
public PacketListener(Plugin plugin, PacketSbManager manager) {
diff --git a/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketSbManager.java b/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketSbManager.java
index 6f90b5c8..ecfed710 100644
--- a/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketSbManager.java
+++ b/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PacketSbManager.java
@@ -41,9 +41,8 @@ public PacketSbManager(ScoreboardStats plugin) {
* @return the scoreboard instance
*/
public PlayerScoreboard getScoreboard(Player player) {
- PlayerScoreboard scoreboard = scoreboards
+ return scoreboards
.computeIfAbsent(player.getUniqueId(), key -> new PlayerScoreboard(player));
- return scoreboard;
}
@Override
diff --git a/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PlayerScoreboard.java b/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PlayerScoreboard.java
index b6058724..083c7ee8 100644
--- a/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PlayerScoreboard.java
+++ b/src/main/java/com/github/games647/scoreboardstats/scoreboard/protocol/PlayerScoreboard.java
@@ -57,7 +57,7 @@ public Objective createSidebarObjective(String objectiveName, String displayName
}
if (objectivesByName.containsKey(objectiveName)) {
- //the objecive already exits. I assume that no other use this unique name
+ //the objective already exits. I assume that no other use this unique name
//so we expect that a other sidebar was showing
Objective objective = objectivesByName.get(objectiveName);
PacketFactory.sendDisplayPacket(objective);
@@ -130,7 +130,7 @@ void resetScore(String scoreName) {
* Very weird that minecraft always ignore the name of the parent objective and
* will remove the score from the complete scoreboard
*/
- objectivesByName.values().stream().forEach(entry -> entry.items.remove(scoreName));
+ objectivesByName.values().forEach(entry -> entry.items.remove(scoreName));
}
void createOrUpdateScore(String scoreName, String parent, int score) {
diff --git a/src/main/java/com/github/games647/scoreboardstats/variables/PluginListener.java b/src/main/java/com/github/games647/scoreboardstats/variables/PluginListener.java
index 173fd8ea..449867aa 100644
--- a/src/main/java/com/github/games647/scoreboardstats/variables/PluginListener.java
+++ b/src/main/java/com/github/games647/scoreboardstats/variables/PluginListener.java
@@ -31,7 +31,7 @@ public void onPluginEnable(PluginEnableEvent enableEvent) {
//Register the listener back again if the plugin is available
String enablePluginName = enableEvent.getPlugin().getName();
Map>, String> defaults = replaceManager.getDefaults();
- defaults.entrySet().stream().forEach(entry -> {
+ defaults.entrySet().forEach(entry -> {
String pluginName = entry.getValue();
if (enablePluginName.equals(entry.getValue())) {
replaceManager.registerDefault(entry.getKey(), pluginName);
diff --git a/src/main/java/com/github/games647/scoreboardstats/variables/Replaceable.java b/src/main/java/com/github/games647/scoreboardstats/variables/Replaceable.java
index dc2146f3..1a93996e 100644
--- a/src/main/java/com/github/games647/scoreboardstats/variables/Replaceable.java
+++ b/src/main/java/com/github/games647/scoreboardstats/variables/Replaceable.java
@@ -7,6 +7,7 @@
*
* @deprecated not fully featured and returns magic values. Will be removed in future versions
*/
+@FunctionalInterface
@Deprecated
public interface Replaceable {
diff --git a/src/main/java/com/github/games647/scoreboardstats/variables/defaults/McmmoVariables.java b/src/main/java/com/github/games647/scoreboardstats/variables/defaults/McmmoVariables.java
index ea83bc58..9af16326 100644
--- a/src/main/java/com/github/games647/scoreboardstats/variables/defaults/McmmoVariables.java
+++ b/src/main/java/com/github/games647/scoreboardstats/variables/defaults/McmmoVariables.java
@@ -31,7 +31,7 @@ private static String[] getSkillVariables() {
.map(String::toLowerCase).collect(Collectors.toSet());
skills.add("powlvl");
- return skills.stream().toArray(String[]::new);
+ return skills.toArray(new String[0]);
}
private final ReplaceManager replaceManager;
diff --git a/src/main/java/com/github/games647/scoreboardstats/variables/defaults/PlaceHolderVariables.java b/src/main/java/com/github/games647/scoreboardstats/variables/defaults/PlaceHolderVariables.java
index 62f3eb59..1cf886a5 100644
--- a/src/main/java/com/github/games647/scoreboardstats/variables/defaults/PlaceHolderVariables.java
+++ b/src/main/java/com/github/games647/scoreboardstats/variables/defaults/PlaceHolderVariables.java
@@ -36,7 +36,7 @@ private static String[] getVariablesPrefixes() {
}
}
- return variables.stream().toArray(String[]::new);
+ return variables.toArray(new String[0]);
}
public PlaceHolderVariables() {
diff --git a/src/test/java/com/github/games647/scoreboardstats/variables/LegacyReplacerTest.java b/src/test/java/com/github/games647/scoreboardstats/variables/LegacyReplacerTest.java
index 0242ab96..92c57c3e 100644
--- a/src/test/java/com/github/games647/scoreboardstats/variables/LegacyReplacerTest.java
+++ b/src/test/java/com/github/games647/scoreboardstats/variables/LegacyReplacerTest.java
@@ -6,7 +6,6 @@
import java.util.logging.Logger;
import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.plugin.messaging.StandardMessenger;
@@ -39,15 +38,11 @@ public void getVariable() throws UnknownVariableException {
Mockito.when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger());
ReplaceManager replaceManager = new ReplaceManager(null, plugin);
- replaceManager.register(new Replaceable() {
-
- @Override
- public int getScoreValue(Player player, String variable) {
- Logger.getAnonymousLogger().log(Level.INFO, "Replaced variable: {0}", variable);
- Assert.assertTrue(variable.charAt(0) == '%');
- Assert.assertTrue(variable.endsWith("%"));
- return 0;
- }
+ replaceManager.register((player, variable) -> {
+ Logger.getAnonymousLogger().log(Level.INFO, "Replaced variable: {0}", variable);
+ Assert.assertTrue(variable.charAt(0) == '%');
+ Assert.assertTrue(variable.endsWith("%"));
+ return 0;
}, "pluginName");
replaceManager.getScore(null, "variableName", "test", -1, true);
diff --git a/src/test/java/com/github/games647/scoreboardstats/variables/ReplaceManagerTest.java b/src/test/java/com/github/games647/scoreboardstats/variables/ReplaceManagerTest.java
index 5af2c9be..94f437a1 100644
--- a/src/test/java/com/github/games647/scoreboardstats/variables/ReplaceManagerTest.java
+++ b/src/test/java/com/github/games647/scoreboardstats/variables/ReplaceManagerTest.java
@@ -55,11 +55,8 @@ public void onReplace(Player player, String variable, ReplaceEvent replaceEvent)
@SuppressWarnings("deprecation")
private void testLegacy(ReplaceManager replaceManager) {
- Replaceable legacyReplaceable = new Replaceable() {
- @Override
- public int getScoreValue(Player player, String variable) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
+ Replaceable legacyReplaceable = (player, variable) -> {
+ throw new UnsupportedOperationException("Not supported yet.");
};
LegacyReplaceWrapper legacyWrapper = new LegacyReplaceWrapper(Bukkit