Make playwire-given carl spin tickets update while the player is logged in
This commit is contained in:
parent
2e280d62de
commit
16b195d2ab
@ -19,8 +19,10 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import org.jooq.SQLDialect;
|
import org.jooq.SQLDialect;
|
||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,15 +87,25 @@ public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
|
|||||||
final int accountId = _clientManager.Get(player).getAccountId();
|
final int accountId = _clientManager.Get(player).getAccountId();
|
||||||
runAsync(() ->
|
runAsync(() ->
|
||||||
{
|
{
|
||||||
try
|
try (Connection c = DBPool.getAccount().getConnection(); Statement statement = c.createStatement())
|
||||||
{
|
{
|
||||||
final int newTickets = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(1)).
|
final String query = "UPDATE bonus SET tickets = tickets + 1 WHERE accountId = " + accountId + ";SELECT tickets FROM bonus WHERE accountId = " + accountId;
|
||||||
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
|
|
||||||
runSync(() ->
|
statement.execute(query);
|
||||||
|
statement.getUpdateCount();
|
||||||
|
statement.getMoreResults();
|
||||||
|
|
||||||
|
ResultSet rs = statement.getResultSet();
|
||||||
|
if (rs.next())
|
||||||
{
|
{
|
||||||
Managers.get(BonusManager.class).Get(player).setTickets(newTickets);
|
final int newTickets = rs.getInt(1);
|
||||||
Managers.get(BonusManager.class).updateCreeperVisual(player, true, C.cAqua);
|
|
||||||
});
|
runSync(() ->
|
||||||
|
{
|
||||||
|
Managers.get(BonusManager.class).Get(player).setTickets(newTickets);
|
||||||
|
Managers.get(BonusManager.class).updateCreeperVisual(player, true, C.cAqua);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -101,7 +113,7 @@ public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Managers.get(BonusManager.class).addPendingExplosion(player, player.getName());
|
//Managers.get(BonusManager.class).addPendingExplosion(player, player.getName());
|
||||||
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L);
|
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user