1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 07:01:22 +01:00

We don't need to delete jobs when inserting

Fixes #824
This commit is contained in:
montlikadani 2020-06-17 11:54:24 +02:00
parent 1a0d87c7b2
commit 9ae9de678b
13 changed files with 48 additions and 78 deletions

View File

@ -13,7 +13,6 @@ import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
public class archive implements Cmd { public class archive implements Cmd {
@Override @Override
@ -37,7 +36,6 @@ public class archive implements Cmd {
} }
Set<JobProgression> AllJobs = jPlayer.getArchivedJobs().getArchivedJobs(); Set<JobProgression> AllJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (AllJobs.isEmpty()) { if (AllJobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob")); sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob"));
return true; return true;

View File

@ -66,14 +66,11 @@ public class edititembonus implements Cmd {
return false; return false;
Player player = (Player) sender; Player player = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return false; return false;
ItemStack iih = Jobs.getNms().getItemInMainHand(player); ItemStack iih = Jobs.getNms().getItemInMainHand(player);
if (iih == null || iih.getType().equals(Material.AIR)) if (iih == null || iih.getType().equals(Material.AIR))
return false; return false;
@ -92,23 +89,24 @@ public class edititembonus implements Cmd {
break; break;
default: default:
break; break;
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline")); sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
Object key = Reflections.getNbt(iih, "JobsItemBoost"); Object key = Reflections.getNbt(iih, "JobsItemBoost");
if (key == null) if (key == null)
return true; return true;
JobItems item = ItemBoostManager.getItemByKey(key.toString()); JobItems item = ItemBoostManager.getItemByKey(key.toString());
if (item == null) if (item == null)
return true; return true;
BoostMultiplier boost = item.getBoost(); BoostMultiplier boost = item.getBoost();
String mc = ChatColor.DARK_GREEN.toString(),
pc = ChatColor.GOLD.toString(),
ec = ChatColor.YELLOW.toString();
for (Job one : item.getJobs()) { for (Job one : item.getJobs()) {
String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list", String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list",
"[jobname]", one.getName(), "[jobname]", one.getName(),
@ -120,10 +118,6 @@ public class edititembonus implements Cmd {
return true; return true;
} }
String mc = ChatColor.DARK_GREEN.toString();
String pc = ChatColor.GOLD.toString();
String ec = ChatColor.YELLOW.toString();
private static String formatText(double amount) { private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%"); return ((amount > 0 ? "+" : "") + amount + "%");
} }

View File

@ -16,10 +16,9 @@ public class entitylist implements Cmd {
return true; return true;
} }
String msg = ""; String msg = "",
c1 = "&e",
String c1 = "&e"; c2 = "&6";
String c2 = "&6";
int i = 0; int i = 0;
for (EntityType type : EntityType.values()) { for (EntityType type : EntityType.values()) {

View File

@ -40,9 +40,7 @@ public class expboost implements Cmd {
} }
if (args.length > 2) { if (args.length > 2) {
int sec = 0; int sec = 0, min = 0, hour = 0;
int min = 0;
int hour = 0;
if (!time.isEmpty()) { if (!time.isEmpty()) {
if (time.contains("s")) { if (time.contains("s")) {
@ -133,9 +131,7 @@ public class expboost implements Cmd {
} }
if (!time.isEmpty()) { if (!time.isEmpty()) {
int sec = 0; int sec = 0, min = 0, hour = 0;
int min = 0;
int hour = 0;
if (time.contains("s")) { if (time.contains("s")) {
sec = Integer.parseInt(time.split("s")[0]); sec = Integer.parseInt(time.split("s")[0]);

View File

@ -70,12 +70,11 @@ public class glog implements Cmd {
return; return;
} }
int count = 1; int count = 1, max = 10;
int max = 10;
double totalMoney = 0; double totalMoney = 0,
double totalExp = 0; totalExp = 0,
double totalPoints = 0; totalPoints = 0;
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.topline")); sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.topline"));
for (Entry<LogAmounts, Double> one : unsortMap.entrySet()) { for (Entry<LogAmounts, Double> one : unsortMap.entrySet()) {

View File

@ -69,9 +69,15 @@ public class itembonus implements Cmd {
if (boost.get(oneC) != 0D) if (boost.get(oneC) != 0D)
any = true; any = true;
} }
if (!any) if (!any)
continue; continue;
String msg = null;
String mc = ChatColor.DARK_GREEN.toString(),
pc = ChatColor.GOLD.toString(),
ec = ChatColor.YELLOW.toString(),
msg = null;
if (jPlayer.isInJob(one)) if (jPlayer.isInJob(one))
msg = Jobs.getLanguage().getMessage("command.itembonus.output.list", msg = Jobs.getLanguage().getMessage("command.itembonus.output.list",
"[jobname]", one.getName(), "[jobname]", one.getName(),
@ -100,10 +106,6 @@ public class itembonus implements Cmd {
return true; return true;
} }
String mc = ChatColor.DARK_GREEN.toString();
String pc = ChatColor.GOLD.toString();
String ec = ChatColor.YELLOW.toString();
private static String formatText(double amount) { private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%"); return ((amount > 0 ? "+" : "") + amount + "%");
} }

View File

@ -77,9 +77,9 @@ public class log implements Cmd {
for (Entry<String, Log> l : logList.entrySet()) { for (Entry<String, Log> l : logList.entrySet()) {
Log one = l.getValue(); Log one = l.getValue();
HashMap<String, LogAmounts> AmountList = one.getAmountList(); HashMap<String, LogAmounts> AmountList = one.getAmountList();
double totalMoney = 0; double totalMoney = 0,
double totalExp = 0; totalExp = 0,
double totalPoints = 0; totalPoints = 0;
for (Entry<String, Double> oneSorted : unsortMap.entrySet()) { for (Entry<String, Double> oneSorted : unsortMap.entrySet()) {
for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) { for (Entry<String, LogAmounts> oneMap : AmountList.entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) { if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) {

View File

@ -40,9 +40,7 @@ public class moneyboost implements Cmd {
} }
if (args.length > 2) { if (args.length > 2) {
int sec = 0; int sec = 0, min = 0, hour = 0;
int min = 0;
int hour = 0;
if (!time.isEmpty()) { if (!time.isEmpty()) {
if (time.contains("s")) { if (time.contains("s")) {
@ -133,9 +131,7 @@ public class moneyboost implements Cmd {
} }
if (!time.isEmpty()) { if (!time.isEmpty()) {
int sec = 0; int sec = 0, min = 0, hour = 0;
int min = 0;
int hour = 0;
if (time.contains("s")) { if (time.contains("s")) {
sec = Integer.parseInt(time.split("s")[0]); sec = Integer.parseInt(time.split("s")[0]);

View File

@ -40,9 +40,7 @@ public class pointboost implements Cmd {
} }
if (args.length > 2) { if (args.length > 2) {
int sec = 0; int sec = 0, min = 0, hour = 0;
int min = 0;
int hour = 0;
if (!time.isEmpty()) { if (!time.isEmpty()) {
if (time.contains("s")) { if (time.contains("s")) {
@ -133,9 +131,7 @@ public class pointboost implements Cmd {
} }
if (!time.isEmpty()) { if (!time.isEmpty()) {
int sec = 0; int sec = 0, min = 0, hour = 0;
int min = 0;
int hour = 0;
if (time.contains("s")) { if (time.contains("s")) {
sec = Integer.parseInt(time.split("s")[0]); sec = Integer.parseInt(time.split("s")[0]);

View File

@ -385,9 +385,9 @@ public class ConfigManager {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public KeyValues getKeyValue(String myKey, ActionType actionType, String jobName) { public KeyValues getKeyValue(String myKey, ActionType actionType, String jobName) {
String type = null; String type = null,
String subType = ""; subType = "",
String meta = ""; meta = "";
int id = 0; int id = 0;
if (myKey.contains("-")) { if (myKey.contains("-")) {
@ -904,8 +904,8 @@ public class ConfigManager {
continue; continue;
} }
List<String> requires = permissionSection.getStringList("requires"); List<String> requires = permissionSection.getStringList("requires"),
List<String> perform = permissionSection.getStringList("perform"); perform = permissionSection.getStringList("perform");
jobConditions.add(new JobConditions(ConditionKey.toLowerCase(), requires, perform)); jobConditions.add(new JobConditions(ConditionKey.toLowerCase(), requires, perform));
} }
} }
@ -1132,9 +1132,9 @@ public class ConfigManager {
int chance = sqsection.getInt("Chance", 100); int chance = sqsection.getInt("Chance", 100);
List<String> commands = sqsection.getStringList("RewardCommands"); List<String> commands = sqsection.getStringList("RewardCommands"),
List<String> desc = sqsection.getStringList("RewardDesc"); desc = sqsection.getStringList("RewardDesc"),
List<String> areas = sqsection.getStringList("RestrictedAreas"); areas = sqsection.getStringList("RestrictedAreas");
if (sqsection.isInt("fromLevel")) if (sqsection.isInt("fromLevel"))
quest.setMinLvl(sqsection.getInt("fromLevel")); quest.setMinLvl(sqsection.getInt("fromLevel"));
@ -1159,9 +1159,9 @@ public class ConfigManager {
} }
job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1)); job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1));
Integer softIncomeLimit = null; Integer softIncomeLimit = null,
Integer softExpLimit = null; softExpLimit = null,
Integer softPointsLimit = null; softPointsLimit = null;
if (jobSection.isInt("softIncomeLimit")) if (jobSection.isInt("softIncomeLimit"))
softIncomeLimit = jobSection.getInt("softIncomeLimit"); softIncomeLimit = jobSection.getInt("softIncomeLimit");
if (jobSection.isInt("softExpLimit")) if (jobSection.isInt("softExpLimit"))
@ -1175,10 +1175,10 @@ public class ConfigManager {
if (typeSection != null) { if (typeSection != null) {
for (String key : typeSection.getKeys(false)) { for (String key : typeSection.getKeys(false)) {
ConfigurationSection section = typeSection.getConfigurationSection(key); ConfigurationSection section = typeSection.getConfigurationSection(key);
String myKey = key; String myKey = key,
String type = null; type = null,
String subType = ""; subType = "",
String meta = ""; meta = "";
int id = 0; int id = 0;
if (myKey.contains("-")) { if (myKey.contains("-")) {

View File

@ -21,11 +21,9 @@ import com.gamingmesh.jobs.stuff.Util;
public class NameTranslatorManager { public class NameTranslatorManager {
public HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>(); private final HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>();
public ArrayList<NameList> ListOfEntities = new ArrayList<>(); private final ArrayList<NameList> ListOfEntities = new ArrayList<>(), ListOfColors = new ArrayList<>();
public HashMap<String, NameList> ListOfEnchants = new HashMap<>(); private final HashMap<String, NameList> ListOfEnchants = new HashMap<>(), ListOfMMEntities = new HashMap<>();
public HashMap<String, NameList> ListOfMMEntities = new HashMap<>();
public ArrayList<NameList> ListOfColors = new ArrayList<>();
public String Translate(String materialName, JobInfo info) { public String Translate(String materialName, JobInfo info) {
return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName()); return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());

View File

@ -414,7 +414,7 @@ public abstract class JobsDAO {
public String getQuery() { public String getQuery() {
String rp = ""; String rp = "";
List<JobsTableInterface> uniques = new ArrayList<JobsTableInterface>(); List<JobsTableInterface> uniques = new ArrayList<>();
for (JobsTableInterface one : this.getInterface()) { for (JobsTableInterface one : this.getInterface()) {
if (one.isUnique()) { if (one.isUnique()) {
uniques.add(one); uniques.add(one);
@ -1125,14 +1125,6 @@ public abstract class JobsDAO {
PreparedStatement prestt = null; PreparedStatement prestt = null;
ResultSet res2 = null; ResultSet res2 = null;
try { try {
prestt = conn.prepareStatement("DELETE FROM `" + DBTables.JobNameTable.getTableName()
+ "` WHERE `" + jobsNameTableFields.name.getCollumn() + "` = ?;");
prestt.setString(1, job.getName());
prestt.execute();
close(prestt);
prestt = null;
prestt = conn.prepareStatement("INSERT INTO `" + DBTables.JobNameTable.getTableName() + "` (`" + jobsNameTableFields.name.getCollumn() + "`) VALUES (?);", prestt = conn.prepareStatement("INSERT INTO `" + DBTables.JobNameTable.getTableName() + "` (`" + jobsNameTableFields.name.getCollumn() + "`) VALUES (?);",
Statement.RETURN_GENERATED_KEYS); Statement.RETURN_GENERATED_KEYS);
prestt.setString(1, job.getName()); prestt.setString(1, job.getName());

View File

@ -12,7 +12,7 @@ public class JobsMySQL extends JobsDAO {
JobsMySQL(Jobs plugin, String hostname, String database, String username, String password, String prefix, boolean certificate, boolean ssl, boolean autoReconnect) { JobsMySQL(Jobs plugin, String hostname, String database, String username, String password, String prefix, boolean certificate, boolean ssl, boolean autoReconnect) {
super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database
+ "?maxReconnects=1&useUnicode=true&characterEncoding=UTF-8&autoReconnect=" + autoReconnect + "&useSSL=" + ssl + "?maxReconnects=1&useUnicode=true&characterEncoding=utf8&autoReconnect=" + autoReconnect + "&useSSL=" + ssl
+ "&verifyServerCertificate=" + certificate, username, password, prefix); + "&verifyServerCertificate=" + certificate, username, password, prefix);
setDbType(DataBaseType.MySQL); setDbType(DataBaseType.MySQL);
} }