mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 12:05:16 +01:00
Jobs toggles will not be saved from now instantly when get income
This commit is contained in:
parent
2cfff7a53b
commit
5d856f0fbc
@ -26,31 +26,32 @@ public class toggle implements Cmd {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
String PlayerName = player.getName();
|
||||
if (PlayerName == null || !args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) {
|
||||
if (!args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "toggle");
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerUUID = player.getUniqueId().toString();
|
||||
|
||||
if (args[0].equalsIgnoreCase("actionbar")) {
|
||||
if (ToggleBarHandling.getActionBarToggle().containsKey(PlayerName)) {
|
||||
if (ToggleBarHandling.getActionBarToggle().get(PlayerName)) {
|
||||
ToggleBarHandling.getActionBarToggle().put(PlayerName, false);
|
||||
if (ToggleBarHandling.getActionBarToggle().containsKey(playerUUID)) {
|
||||
if (ToggleBarHandling.getActionBarToggle().get(playerUUID)) {
|
||||
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
|
||||
} else {
|
||||
ToggleBarHandling.getActionBarToggle().put(PlayerName, true);
|
||||
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
|
||||
}
|
||||
} else {
|
||||
ToggleBarHandling.getActionBarToggle().put(PlayerName, true);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
|
||||
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("bossbar")) {
|
||||
if (ToggleBarHandling.getBossBarToggle().containsKey(PlayerName)) {
|
||||
if (ToggleBarHandling.getBossBarToggle().get(PlayerName)) {
|
||||
ToggleBarHandling.getBossBarToggle().put(PlayerName, false);
|
||||
if (ToggleBarHandling.getBossBarToggle().containsKey(playerUUID)) {
|
||||
if (ToggleBarHandling.getBossBarToggle().get(playerUUID)) {
|
||||
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
|
||||
@ -58,12 +59,12 @@ public class toggle implements Cmd {
|
||||
jPlayer.hideBossBars();
|
||||
|
||||
} else {
|
||||
ToggleBarHandling.getBossBarToggle().put(PlayerName, true);
|
||||
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
|
||||
}
|
||||
} else {
|
||||
ToggleBarHandling.getBossBarToggle().put(PlayerName, true);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
|
||||
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,12 @@ public class BossBarManager {
|
||||
if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1))
|
||||
return;
|
||||
|
||||
String playername = player.getUserName();
|
||||
if (!ToggleBarHandling.getBossBarToggle().containsKey(playername) && Jobs.getGCManager().BossBarsMessageByDefault)
|
||||
ToggleBarHandling.getBossBarToggle().put(playername, true);
|
||||
|
||||
if (!ToggleBarHandling.getBossBarToggle().containsKey(playername))
|
||||
String playerUUID = player.getPlayer().getUniqueId().toString();
|
||||
if (!Jobs.getGCManager().BossBarsMessageByDefault)
|
||||
return;
|
||||
|
||||
Boolean show = ToggleBarHandling.getBossBarToggle().get(playername);
|
||||
Boolean show = ToggleBarHandling.getBossBarToggle().get(playerUUID) == null ? true :
|
||||
ToggleBarHandling.getBossBarToggle().get(playerUUID);
|
||||
|
||||
if (!show)
|
||||
return;
|
||||
|
@ -474,7 +474,8 @@ public abstract class JobsDAO {
|
||||
if (one.isUnique()) {
|
||||
uniques.add(one);
|
||||
}
|
||||
rp += ", " + "`" + one.getCollumn() + "` " + one.getType();
|
||||
|
||||
rp += " , `" + one.getCollumn() + "` " + one.getType();
|
||||
}
|
||||
|
||||
String unique = "";
|
||||
@ -656,7 +657,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ?;");
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ?;");
|
||||
prest.setInt(1, id);
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
@ -688,7 +689,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.JobsTable.getTableName() + "`;");
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + getJobsTableName() + "`;");
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
int id = res.getInt(JobsTableFields.userid.getCollumn());
|
||||
@ -870,7 +871,7 @@ public abstract class JobsDAO {
|
||||
return;
|
||||
PreparedStatement prest = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("DELETE FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.level.getCollumn() + "` <= ?;");
|
||||
prest = conn.prepareStatement("DELETE FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.level.getCollumn() + "` <= ?;");
|
||||
prest.setInt(1, Jobs.getGCManager().DBCleaningJobsLvl);
|
||||
prest.execute();
|
||||
} catch (SQLException e) {
|
||||
@ -1053,7 +1054,7 @@ public abstract class JobsDAO {
|
||||
ResultSet res = null;
|
||||
ResultSet res2 = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.job + "` = ?;");
|
||||
prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.job + "` = ?;");
|
||||
prest.setString(1, JobName);
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
@ -1063,7 +1064,7 @@ public abstract class JobsDAO {
|
||||
|
||||
Job job = Jobs.getJob(JobName);
|
||||
if (job != null && job.getId() != 0) {
|
||||
prest2 = conn.prepareStatement("SELECT COUNT(*) FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;");
|
||||
prest2 = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;");
|
||||
prest2.setInt(1, job.getId());
|
||||
res2 = prest2.executeQuery();
|
||||
while (res2.next()) {
|
||||
@ -1114,7 +1115,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ?;");
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ?;");
|
||||
prest.setInt(1, info.getID());
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
@ -1278,7 +1279,7 @@ public abstract class JobsDAO {
|
||||
try {
|
||||
int level = job.getLevel();
|
||||
Double exp = job.getExperience();
|
||||
prest = conn.prepareStatement("INSERT INTO `" + DBTables.JobsTable.getTableName() + "` (`" + JobsTableFields.userid.getCollumn() + "`, `" + JobsTableFields.jobid.getCollumn()
|
||||
prest = conn.prepareStatement("INSERT INTO `" + getJobsTableName() + "` (`" + JobsTableFields.userid.getCollumn() + "`, `" + JobsTableFields.jobid.getCollumn()
|
||||
+ "`, `" + JobsTableFields.level.getCollumn() + "`, `" + JobsTableFields.experience.getCollumn() + "`) VALUES (?, ?, ?, ?);");
|
||||
prest.setInt(1, jPlayer.getUserId());
|
||||
prest.setInt(2, job.getJob().getId());
|
||||
@ -1306,7 +1307,7 @@ public abstract class JobsDAO {
|
||||
int exp = (int) prog.getExperience();
|
||||
if (exp < 0)
|
||||
exp = 0;
|
||||
prest = conn.prepareStatement("INSERT INTO `" + DBTables.JobsTable.getTableName() + "` (`" + JobsTableFields.userid.getCollumn() + "`, `" + JobsTableFields.jobid.getCollumn()
|
||||
prest = conn.prepareStatement("INSERT INTO `" + getJobsTableName() + "` (`" + JobsTableFields.userid.getCollumn() + "`, `" + JobsTableFields.jobid.getCollumn()
|
||||
+ "`, `" + JobsTableFields.level.getCollumn() + "`, `" + JobsTableFields.experience.getCollumn() + "`) VALUES (?, ?, ?, ?);");
|
||||
prest.setInt(1, jPlayer.getUserId());
|
||||
prest.setInt(2, prog.getJob().getId());
|
||||
@ -1435,7 +1436,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
boolean ok = true;
|
||||
try {
|
||||
prest = conn.prepareStatement("DELETE FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ? AND `" + JobsTableFields.jobid.getCollumn()
|
||||
prest = conn.prepareStatement("DELETE FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ? AND `" + JobsTableFields.jobid.getCollumn()
|
||||
+ "` = ?;");
|
||||
prest.setInt(1, jPlayer.getUserId());
|
||||
prest.setInt(2, job.getId());
|
||||
@ -1730,7 +1731,7 @@ public abstract class JobsDAO {
|
||||
return;
|
||||
PreparedStatement prest = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("UPDATE `" + DBTables.JobsTable.getTableName() + "` SET `" + JobsTableFields.level.getCollumn() + "` = ?, `" + JobsTableFields.experience.getCollumn()
|
||||
prest = conn.prepareStatement("UPDATE `" + getJobsTableName() + "` SET `" + JobsTableFields.level.getCollumn() + "` = ?, `" + JobsTableFields.experience.getCollumn()
|
||||
+ "` = ? WHERE `" + JobsTableFields.userid.getCollumn() + "` = ? AND `" + JobsTableFields.jobid.getCollumn() + "` = ?;");
|
||||
for (JobProgression progression : player.getJobProgression()) {
|
||||
prest.setInt(1, progression.getLevel());
|
||||
@ -2370,7 +2371,7 @@ public abstract class JobsDAO {
|
||||
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT `" + JobsTableFields.userid.getCollumn() + "`, `" + JobsTableFields.level.getCollumn() + "`, `" + JobsTableFields.experience.getCollumn() + "` FROM `"
|
||||
+ DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.jobid.getCollumn() + "` LIKE ? ORDER BY `" + JobsTableFields.level.getCollumn() + "` DESC, LOWER("
|
||||
+ getJobsTableName() + "` WHERE `" + JobsTableFields.jobid.getCollumn() + "` LIKE ? ORDER BY `" + JobsTableFields.level.getCollumn() + "` DESC, LOWER("
|
||||
+ JobsTableFields.experience.getCollumn() + ") DESC LIMIT " + limit + ", 50;");
|
||||
prest.setInt(1, job.getId());
|
||||
res = prest.executeQuery();
|
||||
@ -2407,7 +2408,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + DBTables.JobsTable.getTableName() + "` WHERE `" + JobsTableFields.jobid.getCollumn() + "` = ?;");
|
||||
prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid.getCollumn() + "` = ?;");
|
||||
prest.setInt(1, job.getId());
|
||||
res = prest.executeQuery();
|
||||
if (res.next()) {
|
||||
@ -2481,4 +2482,8 @@ public abstract class JobsDAO {
|
||||
return map;
|
||||
}
|
||||
|
||||
public String getJobsTableName() {
|
||||
return DBTables.JobsTable.getTableName();
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.gamingmesh.jobs.dao;
|
||||
|
||||
import com.gamingmesh.jobs.dao.JobsDAO.TablesFieldsType;
|
||||
|
||||
public interface JobsTableInterface {
|
||||
|
||||
String getCollumn();
|
||||
|
@ -155,11 +155,10 @@ public class BufferedEconomy {
|
||||
economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
|
||||
|
||||
if (ServerTaxesAccount.isOnline()) {
|
||||
if (!ToggleBarHandling.getActionBarToggle().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault)
|
||||
ToggleBarHandling.getActionBarToggle().put(ServerTaxesAccountname, true);
|
||||
if (ToggleBarHandling.getActionBarToggle().containsKey(ServerTaxesAccountname) && ToggleBarHandling.getActionBarToggle().get(ServerTaxesAccountname))
|
||||
Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname), Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100)
|
||||
/ 100.0));
|
||||
if (Jobs.getGCManager().ActionBarsMessageByDefault) {
|
||||
Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname),
|
||||
Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100) / 100.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,18 +222,16 @@ public class BufferedEconomy {
|
||||
if (payment.getOfflinePlayer() == null || !payment.getOfflinePlayer().isOnline())
|
||||
return;
|
||||
|
||||
String playername = payment.getOfflinePlayer().getName();
|
||||
|
||||
if (Jobs.getGCManager().ActionBarsMessageByDefault && !ToggleBarHandling.getActionBarToggle().containsKey(playername))
|
||||
ToggleBarHandling.getActionBarToggle().put(playername, true);
|
||||
|
||||
if (!ToggleBarHandling.getActionBarToggle().containsKey(playername))
|
||||
if (!Jobs.getGCManager().ActionBarsMessageByDefault)
|
||||
return;
|
||||
|
||||
if (!payment.containsPayment())
|
||||
return;
|
||||
|
||||
Boolean show = ToggleBarHandling.getActionBarToggle().get(playername);
|
||||
String playerUUID = payment.getOfflinePlayer().getUniqueId().toString();
|
||||
|
||||
Boolean show = ToggleBarHandling.getActionBarToggle().get(playerUUID) == null ? true :
|
||||
ToggleBarHandling.getActionBarToggle().get(playerUUID);
|
||||
Player abp = Bukkit.getPlayer(payment.getOfflinePlayer().getUniqueId());
|
||||
if ((abp != null) && (show.booleanValue())) {
|
||||
String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
|
||||
|
@ -27,6 +27,10 @@ public class ToggleBarHandling {
|
||||
|
||||
if (section != null) {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if (section.getBoolean(one)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bossBarToggle.put(one, section.getBoolean(one));
|
||||
}
|
||||
}
|
||||
@ -37,6 +41,10 @@ public class ToggleBarHandling {
|
||||
|
||||
if (section != null) {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if (section.getBoolean(one)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
actionBarToggle.put(one, section.getBoolean(one));
|
||||
}
|
||||
}
|
||||
@ -57,6 +65,10 @@ public class ToggleBarHandling {
|
||||
|
||||
if (!bossBarToggle.isEmpty()) {
|
||||
for (Entry<String, Boolean> one : bossBarToggle.entrySet()) {
|
||||
if (one.getValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
config.set("bossBar." + one.getKey(), one.getValue());
|
||||
}
|
||||
}
|
||||
@ -67,6 +79,10 @@ public class ToggleBarHandling {
|
||||
|
||||
if (!actionBarToggle.isEmpty()) {
|
||||
for (Entry<String, Boolean> one : actionBarToggle.entrySet()) {
|
||||
if (one.getValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
config.set("actionBar." + one.getKey(), one.getValue());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user