Switch to Java 1.8

This commit is contained in:
GeorgH93 2017-06-10 20:30:39 +02:00
parent 392a2a7c74
commit f931273c00
3 changed files with 56 additions and 96 deletions

View File

@ -78,8 +78,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.1</version>
<configuration> <configuration>
<source>1.7</source> <source>1.8</source>
<target>1.7</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -260,14 +260,7 @@ protected String replacePlaceholders(String query)
protected void runStatementAsync(final String query, final Object... args) protected void runStatementAsync(final String query, final Object... args)
{ {
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> runStatement(query, args));
{
@Override
public void run()
{
runStatement(query, args);
}
});
} }
protected void runStatement(final String query, final Object... args) protected void runStatement(final String query, final Object... args)
@ -308,11 +301,7 @@ public void saveBackpack(final Backpack backpack)
final int id = backpack.getOwnerID(), usedSerializer = itsSerializer.getUsedSerializer(); final int id = backpack.getOwnerID(), usedSerializer = itsSerializer.getUsedSerializer();
final String nameOrUUID = getPlayerNameOrUUID(backpack.getOwner()), name = backpack.getOwner().getName(); final String nameOrUUID = getPlayerNameOrUUID(backpack.getOwner()), name = backpack.getOwner().getName();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
{
@Override
public void run()
{
try(Connection connection = getConnection()) try(Connection connection = getConnection())
{ {
if(id <= 0) if(id <= 0)
@ -326,14 +315,7 @@ public void run()
{ {
final int newID = rs.getInt(1); final int newID = rs.getInt(1);
DBTools.runStatement(connection, queryInsertBp, newID, data, usedSerializer); DBTools.runStatement(connection, queryInsertBp, newID, data, usedSerializer);
plugin.getServer().getScheduler().runTask(plugin, new Runnable() plugin.getServer().getScheduler().runTask(plugin, () -> backpack.setOwnerID(newID));
{
@Override
public void run()
{
backpack.setOwnerID(newID);
}
});
} }
else else
{ {
@ -351,18 +333,13 @@ public void run()
{ {
e.printStackTrace(); e.printStackTrace();
} }
}
}); });
} }
@Override @Override
protected void loadBackpack(final OfflinePlayer player, final Callback<Backpack> callback) protected void loadBackpack(final OfflinePlayer player, final Callback<Backpack> callback)
{ {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
{
@Override
public void run()
{
try(Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(queryGetBP)) try(Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(queryGetBP))
{ {
ps.setString(1, getPlayerNameOrUUID(player)); ps.setString(1, getPlayerNameOrUUID(player));
@ -383,11 +360,7 @@ public void run()
data = null; data = null;
} }
} }
plugin.getServer().getScheduler().runTask(plugin, new Runnable() plugin.getServer().getScheduler().runTask(plugin, () -> {
{
@Override
public void run()
{
ItemStack[] its = itsSerializer.deserialize(data, version); ItemStack[] its = itsSerializer.deserialize(data, version);
if(its != null) if(its != null)
{ {
@ -397,21 +370,12 @@ public void run()
{ {
callback.onFail(); callback.onFail();
} }
}
}); });
} }
catch(SQLException e) catch(SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
plugin.getServer().getScheduler().runTask(plugin, new Runnable() plugin.getServer().getScheduler().runTask(plugin, callback::onFail);
{
@Override
public void run()
{
callback.onFail();
}
});
}
} }
}); });
} }

View File

@ -139,13 +139,9 @@ public void updatePlayer(final Player player)
{ {
if(useUUIDs) if(useUUIDs)
{ {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
@Override
public void run()
{
runStatement(queryUpdatePlayerAdd, player.getName(), getPlayerFormattedUUID(player)); runStatement(queryUpdatePlayerAdd, player.getName(), getPlayerFormattedUUID(player));
runStatement("UPDATE `" + tablePlayers + "` SET `" + fieldPlayerName + "`=? WHERE `" + fieldPlayerUUID + "`=?;", player.getName(), getPlayerFormattedUUID(player)); runStatement("UPDATE `" + tablePlayers + "` SET `" + fieldPlayerName + "`=? WHERE `" + fieldPlayerUUID + "`=?;", player.getName(), getPlayerFormattedUUID(player));
}
}); });
} }
else else