1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

resetlimit all should reset limits for everyone and not just online

players
This commit is contained in:
Zrips 2023-09-20 12:24:41 +03:00
parent 157238b01e
commit 2bfd5bef5e
3 changed files with 26 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
@ -15,14 +16,14 @@ public class resetlimit implements Cmd {
}
if (args[0].equalsIgnoreCase("all")) {
for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl);
if (jPlayer != null) {
jPlayer.resetPaymentLimit();
}
for (JobsPlayer jPlayer : Jobs.getPlayerManager().getPlayersCache().values()) {
jPlayer.nullPaymentLimits();
}
Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", "");
Jobs.getDBManager().getDB().clearLimitsTable();
Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", "", "%playerdisplayname%", "");
return true;
}

View File

@ -466,6 +466,10 @@ public class JobsPlayer {
setSaved(false);
}
public void nullPaymentLimits() {
paymentLimits = null;
}
/**
* @return an unmodifiable list of job progressions
*/

View File

@ -1423,6 +1423,21 @@ public abstract class JobsDAO {
}
}
public synchronized void clearLimitsTable() {
JobsConnection conn = getConnection();
if (conn == null)
return;
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("DELETE FROM `" + DBTables.LimitsTable.getTableName() + "`;");
ps.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
close(ps);
}
}
public synchronized PaymentData getPlayersLimits(JobsPlayer jPlayer) {
PaymentData data = new PaymentData();
JobsConnection conn = getConnection();