Merge branch 'update/clans' of github.com:Mineplex-LLC/Minecraft-PC into update/clans
This commit is contained in:
commit
853fe31fbe
|
@ -1,7 +1,9 @@
|
|||
package mineplex.game.clans.economy;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -19,6 +21,8 @@ public class GoldRepository {
|
|||
}
|
||||
|
||||
public void rewardGold(final Callback<Boolean> callback, final int accountId, final int gold)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
|
||||
{
|
||||
try (Connection connection = DBPool.getAccount().getConnection())
|
||||
{
|
||||
|
@ -34,7 +38,8 @@ public class GoldRepository {
|
|||
callback.run(true);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
if (callback != null)
|
||||
|
@ -42,6 +47,7 @@ public class GoldRepository {
|
|||
callback.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setGold(final Callback<Boolean> callback, final int accountId, final int gold)
|
||||
|
@ -51,6 +57,8 @@ public class GoldRepository {
|
|||
throw new IllegalArgumentException("gold cannot be negative");
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
|
||||
{
|
||||
try (Connection connection = DBPool.getAccount().getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD);
|
||||
|
@ -59,12 +67,12 @@ public class GoldRepository {
|
|||
statement.setInt(3, gold);
|
||||
statement.setInt(4, gold);
|
||||
statement.executeUpdate();
|
||||
if (callback != null)
|
||||
{
|
||||
if (callback != null) {
|
||||
callback.run(true);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
if (callback != null)
|
||||
|
@ -72,5 +80,6 @@ public class GoldRepository {
|
|||
callback.run(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue