mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
resetlimit all should reset limits for everyone and not just online
players
This commit is contained in:
parent
157238b01e
commit
2bfd5bef5e
@ -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;
|
||||
}
|
||||
|
||||
|
@ -466,6 +466,10 @@ public class JobsPlayer {
|
||||
setSaved(false);
|
||||
}
|
||||
|
||||
public void nullPaymentLimits() {
|
||||
paymentLimits = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable list of job progressions
|
||||
*/
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user