This commit is contained in:
thiesyy 2019-10-24 22:49:50 +02:00
parent 50ce6ea26e
commit 639dabbc5d
No known key found for this signature in database
GPG Key ID: 3560E52BC0B3CA40
1 changed files with 14 additions and 17 deletions

View File

@ -52,7 +52,6 @@ public class FridaysForFuture {
coins.put(pid, coinsp);
}
}catch(Exception e) {
//e.printStackTrace();
}
@ -105,7 +104,7 @@ public void printdgag(Long id) {
tbot.execute(new SendMessage(id, "Der Überfall wurde geschlossen. Es geht los!"));
sleep(1000 * 5);
for (Long pid : users) {
takeMoney(pid, 3000 / users.size());
takeMoney(pid, (3000 / users.size()));
}
tbot.execute(
new SendMessage(id, "Jedem spieler wurden " + 3000 / users.size() + " Dollar eingezogen."));
@ -152,7 +151,6 @@ public void printdgag(Long id) {
}
users.clear();
names.clear();
coins.clear();
heiststate = HState.NotRunning;
shot.clear();
@ -171,25 +169,21 @@ public void printdgag(Long id) {
private void addMoney(Long pid, int Money) {
int Coins = GetMoney(pid);
System.out.println(Coins+"add");
if(coins.containsKey(pid))
coins.remove(pid);
coins.put(pid, (Coins + Money));
System.out.println((Coins + Money) + " add2");
refreshCoinDB(pid);
}
private void takeMoney(Long pid, int Money) {
int Coins = GetMoney(pid);
System.out.println(Coins+"take");
if (Coins <= Money) {
Coins = Money+Defaultmoney;
System.out.println(Coins+"adadd");
int geld = GetMoney(pid);
if (geld <= Money) {
geld = Money+Defaultmoney;
}
if(coins.containsKey(pid))
coins.remove(pid);
coins.put(pid, Coins - Money);
System.out.println(Coins-Money);
coins.put(pid, geld - Money);
refreshCoinDB(pid);
}
@ -201,13 +195,16 @@ public void printdgag(Long id) {
private void refreshCoinDB(Long pid) {
try {
//System.out.println(pid+ " " + coins.get(pid));
ResultSet get = Dbmgr.query("SELECT * FROM spamforfuturebot.coins WHERE id = '" + pid + "';");
if (get.next())
Dbmgr.update("DELETE FROM spamforfuturebot.coins WHERE id = '"+pid+"'");
Dbmgr.update("INSERT INTO spamforfuturebot.coins(id,coins) VALUES('"+pid+"','"+coins.get(pid)+"');");
if (get.next()) {
Dbmgr.update("UPDATE spamforfuturebot.coins SET coins = '"+coins.get(pid)+"' WHERE id = '"+pid+"';");
}else {
Dbmgr.update("INSERT INTO spamforfuturebot.coins(id,coins) VALUES('"+pid+"','"+coins.get(pid)+"');");
}
} catch (SQLException e) {
e.printStackTrace();