mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-14 10:45:23 +01:00
Switch to Java 1.8
This commit is contained in:
parent
392a2a7c74
commit
f931273c00
4
pom.xml
4
pom.xml
@ -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>
|
||||||
|
@ -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,110 +301,81 @@ 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, () -> {
|
||||||
{
|
try(Connection connection = getConnection())
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try(Connection connection = getConnection())
|
if(id <= 0)
|
||||||
{
|
{
|
||||||
if(id <= 0)
|
try(PreparedStatement ps = connection.prepareStatement(queryGetPlayerID))
|
||||||
{
|
{
|
||||||
try(PreparedStatement ps = connection.prepareStatement(queryGetPlayerID))
|
ps.setString(1, nameOrUUID);
|
||||||
|
try(ResultSet rs = ps.executeQuery())
|
||||||
{
|
{
|
||||||
ps.setString(1, nameOrUUID);
|
if(rs.next())
|
||||||
try(ResultSet rs = ps.executeQuery())
|
|
||||||
{
|
{
|
||||||
if(rs.next())
|
final int newID = rs.getInt(1);
|
||||||
{
|
DBTools.runStatement(connection, queryInsertBp, newID, data, usedSerializer);
|
||||||
final int newID = rs.getInt(1);
|
plugin.getServer().getScheduler().runTask(plugin, () -> backpack.setOwnerID(newID));
|
||||||
DBTools.runStatement(connection, queryInsertBp, newID, data, usedSerializer);
|
}
|
||||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable()
|
else
|
||||||
{
|
{
|
||||||
@Override
|
plugin.getLogger().warning("Failed saving backpack for: " + name + " (Unable to get players ID from database)");
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
backpack.setOwnerID(newID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.getLogger().warning("Failed saving backpack for: " + name + " (Unable to get players ID from database)");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
DBTools.runStatement(connection, queryUpdateBp, data, usedSerializer, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(SQLException e)
|
else
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
DBTools.runStatement(connection, queryUpdateBp, data, usedSerializer, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(SQLException e)
|
||||||
|
{
|
||||||
|
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, () -> {
|
||||||
{
|
try(Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(queryGetBP))
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try(Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(queryGetBP))
|
ps.setString(1, getPlayerNameOrUUID(player));
|
||||||
|
final int bpID, version;
|
||||||
|
final byte[] data;
|
||||||
|
try(ResultSet rs = ps.executeQuery())
|
||||||
{
|
{
|
||||||
ps.setString(1, getPlayerNameOrUUID(player));
|
if(rs.next())
|
||||||
final int bpID, version;
|
|
||||||
final byte[] data;
|
|
||||||
try(ResultSet rs = ps.executeQuery())
|
|
||||||
{
|
{
|
||||||
if(rs.next())
|
bpID = rs.getInt(1);
|
||||||
{
|
version = rs.getInt(3);
|
||||||
bpID = rs.getInt(1);
|
data = rs.getBytes(2);
|
||||||
version = rs.getInt(3);
|
|
||||||
data = rs.getBytes(2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bpID = -1;
|
|
||||||
version = 0;
|
|
||||||
data = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable()
|
else
|
||||||
{
|
{
|
||||||
@Override
|
bpID = -1;
|
||||||
public void run()
|
version = 0;
|
||||||
{
|
data = null;
|
||||||
ItemStack[] its = itsSerializer.deserialize(data, version);
|
}
|
||||||
if(its != null)
|
|
||||||
{
|
|
||||||
callback.onResult(new Backpack(player, its, bpID));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callback.onFail();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch(SQLException e)
|
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||||
{
|
ItemStack[] its = itsSerializer.deserialize(data, version);
|
||||||
e.printStackTrace();
|
if(its != null)
|
||||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable()
|
|
||||||
{
|
{
|
||||||
@Override
|
callback.onResult(new Backpack(player, its, bpID));
|
||||||
public void run()
|
}
|
||||||
{
|
else
|
||||||
callback.onFail();
|
{
|
||||||
}
|
callback.onFail();
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
catch(SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
plugin.getServer().getScheduler().runTask(plugin, callback::onFail);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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
|
runStatement(queryUpdatePlayerAdd, player.getName(), getPlayerFormattedUUID(player));
|
||||||
public void run()
|
runStatement("UPDATE `" + tablePlayers + "` SET `" + fieldPlayerName + "`=? WHERE `" + fieldPlayerUUID + "`=?;", player.getName(), getPlayerFormattedUUID(player));
|
||||||
{
|
|
||||||
runStatement(queryUpdatePlayerAdd, player.getName(), getPlayerFormattedUUID(player));
|
|
||||||
runStatement("UPDATE `" + tablePlayers + "` SET `" + fieldPlayerName + "`=? WHERE `" + fieldPlayerUUID + "`=?;", player.getName(), getPlayerFormattedUUID(player));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user