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.JobsPlayer;
public class archive implements Cmd {
@Override
@ -37,7 +36,6 @@ public class archive implements Cmd {
}
Set<JobProgression> AllJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (AllJobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob"));
return true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -414,7 +414,7 @@ public abstract class JobsDAO {
public String getQuery() {
String rp = "";
List<JobsTableInterface> uniques = new ArrayList<JobsTableInterface>();
List<JobsTableInterface> uniques = new ArrayList<>();
for (JobsTableInterface one : this.getInterface()) {
if (one.isUnique()) {
uniques.add(one);
@ -1125,14 +1125,6 @@ public abstract class JobsDAO {
PreparedStatement prestt = null;
ResultSet res2 = null;
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 (?);",
Statement.RETURN_GENERATED_KEYS);
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) {
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);
setDbType(DataBaseType.MySQL);
}