mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Fix Jobs database truncation on updating job ids
This commit is contained in:
parent
0d138d6664
commit
24968f2218
9
.github/ISSUE_TEMPLATE/bug_report.md
vendored
9
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,17 +1,18 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
about: Create a report to help us improve our project
|
||||
title: ''
|
||||
labels: Bug Report
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
***Description of issue:**
|
||||
***Detailed description of the issue:**
|
||||
|
||||
---
|
||||
|
||||
**ERROR (DELETE IF YOU HAVE NO ERROR):**
|
||||
<-- Try to use pastebin.com server if you have long error. -->
|
||||
```
|
||||
####################
|
||||
## PASTE ERROR HERE ##
|
||||
@ -27,7 +28,9 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Server Type (Spigot/Paperspigot/etc):**
|
||||
**Jobs version:**
|
||||
|
||||
**Server Type (Spigot/Paper/etc):**
|
||||
|
||||
**Server Version (using `/ver`):**
|
||||
|
||||
|
4
.github/ISSUE_TEMPLATE/feature_request.md
vendored
4
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -9,6 +9,6 @@ assignees: ''
|
||||
|
||||
**Description of new idea or improvement on existing one**
|
||||
|
||||
**Detailed information what should do**
|
||||
|
||||
|
||||
**Detailed information what should do what and when**
|
||||
<-- Maybe a config example if related -->
|
||||
|
@ -108,9 +108,10 @@ public class GuiManager {
|
||||
} else
|
||||
lore.addAll(Arrays.asList(job.getDescription().split("/n|\\n")));
|
||||
|
||||
if (job.getMaxSlots() != null)
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
|
||||
.getUsedSlots(job)) : 0));
|
||||
if (job.getMaxSlots() != null) {
|
||||
int usedSlots = Jobs.getUsedSlots(job);
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - usedSlots) > 0 ? (job.getMaxSlots() - usedSlots) : 0));
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().ShowActionNames) {
|
||||
lore.add("");
|
||||
|
@ -399,8 +399,7 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
public static File getFolder() {
|
||||
File folder = instance.getDataFolder();
|
||||
if (!folder.exists())
|
||||
folder.mkdirs();
|
||||
folder.mkdirs();
|
||||
return folder;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@ -24,6 +25,7 @@ import com.gamingmesh.jobs.container.Quest;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.container.Title;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
@ -103,7 +105,7 @@ public class Placeholder {
|
||||
|
||||
private String[] vars;
|
||||
private List<Integer> groups = new ArrayList<>();
|
||||
private ChatFilterRule rule = null;
|
||||
private ChatFilterRule rule;
|
||||
private boolean hidden = false;
|
||||
|
||||
JobsPlaceHolders(String... vars) {
|
||||
@ -234,7 +236,7 @@ public class Placeholder {
|
||||
if (!isComplex())
|
||||
return lsInLs;
|
||||
|
||||
Matcher matcher = getRule().getMatcher(text);
|
||||
Matcher matcher = rule.getMatcher(text);
|
||||
if (matcher == null)
|
||||
return lsInLs;
|
||||
|
||||
@ -250,7 +252,7 @@ public class Placeholder {
|
||||
if (!isComplex() || text == null)
|
||||
return lsInLs;
|
||||
|
||||
Matcher matcher = getRule().getMatcher(text);
|
||||
Matcher matcher = rule.getMatcher(text);
|
||||
if (matcher != null && matcher.find()) {
|
||||
try {
|
||||
for (Integer oneG : groups) {
|
||||
@ -429,13 +431,13 @@ public class Placeholder {
|
||||
case user_maxfurncount:
|
||||
return Integer.toString(user.getMaxOwnerShipAllowed(BlockTypes.FURNACE));
|
||||
case user_smokercount:
|
||||
return !plugin.getBlockOwnerShip(BlockTypes.SMOKER).isPresent() ? "0"
|
||||
: Integer.toString(plugin.getBlockOwnerShip(BlockTypes.SMOKER).get().getTotal(uuid));
|
||||
Optional<BlockOwnerShip> blastSmoker = plugin.getBlockOwnerShip(BlockTypes.SMOKER);
|
||||
return !blastSmoker.isPresent() ? "0" : Integer.toString(blastSmoker.get().getTotal(uuid));
|
||||
case user_maxsmokercount:
|
||||
return Integer.toString(user.getMaxOwnerShipAllowed(BlockTypes.SMOKER));
|
||||
case user_blastcount:
|
||||
return !plugin.getBlockOwnerShip(BlockTypes.BLAST_FURNACE).isPresent() ? "0"
|
||||
: Integer.toString(plugin.getBlockOwnerShip(BlockTypes.BLAST_FURNACE).get().getTotal(uuid));
|
||||
Optional<BlockOwnerShip> blastShip = plugin.getBlockOwnerShip(BlockTypes.BLAST_FURNACE);
|
||||
return !blastShip.isPresent() ? "0" : Integer.toString(blastShip.get().getTotal(uuid));
|
||||
case user_maxblastcount:
|
||||
return Integer.toString(user.getMaxOwnerShipAllowed(BlockTypes.BLAST_FURNACE));
|
||||
case user_doneq:
|
||||
@ -498,14 +500,11 @@ public class Placeholder {
|
||||
|
||||
switch (placeHolder) {
|
||||
case limit_$1:
|
||||
CurrencyType t = CurrencyType.getByName(vals.get(0));
|
||||
return Integer.toString(user.getLimit(t));
|
||||
return Integer.toString(user.getLimit(CurrencyType.getByName(vals.get(0))));
|
||||
case plimit_$1:
|
||||
t = CurrencyType.getByName(vals.get(0));
|
||||
return Double.toString(user.getPaymentLimit().getAmount(t));
|
||||
return Double.toString(user.getPaymentLimit().getAmount(CurrencyType.getByName(vals.get(0))));
|
||||
case plimit_tleft_$1:
|
||||
t = CurrencyType.getByName(vals.get(0));
|
||||
return TimeManage.to24hourShort(user.getPaymentLimit().getLeftTime(t));
|
||||
return TimeManage.to24hourShort(user.getPaymentLimit().getLeftTime(CurrencyType.getByName(vals.get(0))));
|
||||
case user_jlevel_$1:
|
||||
return j == null ? "0" : Integer.toString(j.getLevel());
|
||||
case user_jexp_$1:
|
||||
@ -521,10 +520,9 @@ public class Placeholder {
|
||||
case user_jmaxlvl_$1:
|
||||
return j == null ? "0" : Integer.toString(j.getJob().getMaxLevel(user));
|
||||
case user_boost_$1_$2:
|
||||
return vals.size() < 2 || j == null ? "" : simplifyDouble(user.getBoost(j.getJob().getName(),
|
||||
return (vals.size() < 2 || j == null) ? "" : simplifyDouble(user.getBoost(j.getJob().getName(),
|
||||
CurrencyType.getByName(vals.get(1))));
|
||||
case user_jtoplvl_$1_$2:
|
||||
vals = placeHolder.getComplexValues(value);
|
||||
if (vals.size() < 2 || job == null)
|
||||
return "";
|
||||
|
||||
@ -545,10 +543,6 @@ public class Placeholder {
|
||||
return "";
|
||||
}).join();
|
||||
case user_isin_$1:
|
||||
vals = placeHolder.getComplexValues(value);
|
||||
if (vals.isEmpty())
|
||||
return "";
|
||||
|
||||
return job == null ? "no" : convert(user.isInJob(job));
|
||||
case user_job_$1:
|
||||
return j == null ? "" : j.getJob().getName();
|
||||
@ -589,21 +583,16 @@ public class Placeholder {
|
||||
if (job == null)
|
||||
return "";
|
||||
|
||||
if (!Jobs.getCommandManager().hasJobPermission(player, job))
|
||||
return convert(false);
|
||||
|
||||
if (user.isInJob(job))
|
||||
if (!Jobs.getCommandManager().hasJobPermission(player, job) || user.isInJob(job))
|
||||
return convert(false);
|
||||
|
||||
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots())
|
||||
return convert(false);
|
||||
|
||||
int confMaxJobs = Jobs.getGCManager().getMaxJobs();
|
||||
short PlayerMaxJobs = (short) user.getJobProgression().size();
|
||||
if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(user, PlayerMaxJobs))
|
||||
return convert(false);
|
||||
|
||||
return convert(true);
|
||||
short playerMaxJobs = (short) user.getJobProgression().size();
|
||||
return convert(confMaxJobs > 0 && playerMaxJobs >= confMaxJobs
|
||||
&& !Jobs.getPlayerManager().getJobsLimit(user, playerMaxJobs));
|
||||
|
||||
case maxjobs:
|
||||
return Integer.toString(Jobs.getPlayerManager().getMaxJobs(user));
|
||||
|
@ -313,8 +313,10 @@ public class ConfigManager {
|
||||
|
||||
public void changeJobsSettings(String jobName, String path, Object value) {
|
||||
path = path.replace('/', '.');
|
||||
jobName = jobName.toLowerCase();
|
||||
|
||||
for (YmlMaker yml : jobFiles) {
|
||||
if (yml.getConfigFile().getName().contains(jobName.toLowerCase())) {
|
||||
if (yml.getConfigFile().getName().contains(jobName)) {
|
||||
yml.getConfig().set(path, value);
|
||||
yml.saveConfig();
|
||||
break;
|
||||
@ -370,14 +372,14 @@ public class ConfigManager {
|
||||
|
||||
if (myKey.contains("-")) {
|
||||
// uses subType
|
||||
String[] split = myKey.split("-");
|
||||
String[] split = myKey.split("-", 2);
|
||||
if (split.length >= 2) {
|
||||
subType = ":" + split[1];
|
||||
meta = split[1];
|
||||
myKey = split[0];
|
||||
}
|
||||
} else if (myKey.contains(":")) { // when we uses tipped arrow effect types
|
||||
String[] split = myKey.split(":");
|
||||
String[] split = myKey.split(":", 2);
|
||||
meta = split.length > 1 ? split[1] : myKey;
|
||||
subType = ":all";
|
||||
myKey = split[0];
|
||||
@ -445,7 +447,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
if (Version.isCurrentLower(Version.v1_13_R1) && meta.isEmpty())
|
||||
meta = String.valueOf(material.getData());
|
||||
meta = Integer.toString(material.getData());
|
||||
|
||||
c: if (material != CMIMaterial.NONE && material.getMaterial() != null && !material.isAir()) {
|
||||
// Need to include those ones and count as regular blocks
|
||||
@ -596,14 +598,14 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
if (myKey.contains(":")) {
|
||||
subType = myKey.split(":")[1];
|
||||
subType = myKey.split(":", 2)[1];
|
||||
}
|
||||
} else if (actionType == ActionType.SHEAR && !myKey.startsWith("color")) {
|
||||
type = myKey;
|
||||
}
|
||||
|
||||
if (finalMyKey.endsWith("-all") || finalMyKey.endsWith(":all")) {
|
||||
type = finalMyKey.split(":|-")[0];
|
||||
type = finalMyKey.split(":|-", 2)[0];
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
@ -635,9 +637,7 @@ public class ConfigManager {
|
||||
private boolean migrateJobs() {
|
||||
YamlConfiguration oldConf = getJobConfig();
|
||||
if (oldConf == null) {
|
||||
if (!jobsPathFolder.exists()) {
|
||||
jobsPathFolder.mkdirs();
|
||||
}
|
||||
jobsPathFolder.mkdirs();
|
||||
|
||||
if (jobsPathFolder.isDirectory() && jobsPathFolder.listFiles().length == 0)
|
||||
try {
|
||||
@ -762,19 +762,19 @@ public class ConfigManager {
|
||||
// Translating unicode
|
||||
jobFullName = StringEscapeUtils.unescapeJava(jobFullName);
|
||||
|
||||
int maxLevel = jobSection.getInt("max-level", 0);
|
||||
int maxLevel = jobSection.getInt("max-level");
|
||||
if (maxLevel < 0)
|
||||
maxLevel = 0;
|
||||
|
||||
int vipmaxLevel = jobSection.getInt("vip-max-level", 0);
|
||||
int vipmaxLevel = jobSection.getInt("vip-max-level");
|
||||
if (vipmaxLevel < 0)
|
||||
vipmaxLevel = 0;
|
||||
|
||||
Integer maxSlots = jobSection.getInt("slots", 0);
|
||||
Integer maxSlots = jobSection.getInt("slots");
|
||||
if (maxSlots.intValue() <= 0)
|
||||
maxSlots = null;
|
||||
|
||||
Long rejoinCd = jobSection.getLong("rejoinCooldown", 0L);
|
||||
Long rejoinCd = jobSection.getLong("rejoinCooldown");
|
||||
if (rejoinCd < 0L) {
|
||||
rejoinCd = 0L;
|
||||
} else {
|
||||
@ -899,10 +899,10 @@ public class ConfigManager {
|
||||
|
||||
if (item.contains("-")) {
|
||||
// uses subType
|
||||
subType = ":" + item.split("-")[1];
|
||||
subType = ":" + item.split("-", 2)[1];
|
||||
item = item.split("-")[0];
|
||||
} else if (item.contains(":")) { // when we uses tipped arrow effect types
|
||||
item = item.split(":")[0];
|
||||
item = item.split(":", 2)[0];
|
||||
}
|
||||
|
||||
CMIMaterial material = CMIMaterial.get(item + (subType));
|
||||
@ -952,7 +952,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
// Permissions
|
||||
ArrayList<JobPermission> jobPermissions = new ArrayList<>();
|
||||
List<JobPermission> jobPermissions = new ArrayList<>();
|
||||
ConfigurationSection permissionsSection = jobSection.getConfigurationSection("permissions");
|
||||
if (permissionsSection != null) {
|
||||
for (String permissionKey : permissionsSection.getKeys(false)) {
|
||||
@ -964,35 +964,35 @@ public class ConfigManager {
|
||||
|
||||
String node = permissionSection.getString("permission");
|
||||
boolean value = permissionSection.getBoolean("value", true);
|
||||
int levelRequirement = permissionSection.getInt("level", 0);
|
||||
int levelRequirement = permissionSection.getInt("level");
|
||||
jobPermissions.add(new JobPermission(node, value, levelRequirement));
|
||||
}
|
||||
}
|
||||
|
||||
// Conditions
|
||||
ArrayList<JobConditions> jobConditions = new ArrayList<>();
|
||||
List<JobConditions> jobConditions = new ArrayList<>();
|
||||
ConfigurationSection conditionsSection = jobSection.getConfigurationSection("conditions");
|
||||
if (conditionsSection != null) {
|
||||
for (String ConditionKey : conditionsSection.getKeys(false)) {
|
||||
ConfigurationSection permissionSection = conditionsSection.getConfigurationSection(ConditionKey);
|
||||
for (String conditionKey : conditionsSection.getKeys(false)) {
|
||||
ConfigurationSection permissionSection = conditionsSection.getConfigurationSection(conditionKey);
|
||||
if (permissionSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid condition key " + ConditionKey + "!");
|
||||
log.warning("Job " + jobKey + " has an invalid condition key " + conditionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!permissionSection.contains("requires") || !permissionSection.contains("perform")) {
|
||||
log.warning("Job " + jobKey + " has an invalid condition requirement " + ConditionKey + "!");
|
||||
log.warning("Job " + jobKey + " has an invalid condition requirement " + conditionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> requires = permissionSection.getStringList("requires"),
|
||||
perform = permissionSection.getStringList("perform");
|
||||
jobConditions.add(new JobConditions(ConditionKey.toLowerCase(), requires, perform));
|
||||
jobConditions.add(new JobConditions(conditionKey.toLowerCase(), requires, perform));
|
||||
}
|
||||
}
|
||||
|
||||
// Commands
|
||||
ArrayList<JobCommands> jobCommand = new ArrayList<>();
|
||||
List<JobCommands> jobCommand = new ArrayList<>();
|
||||
ConfigurationSection commandsSection = jobSection.getConfigurationSection("commands");
|
||||
if (commandsSection != null) {
|
||||
for (String commandKey : commandsSection.getKeys(false)) {
|
||||
@ -1073,7 +1073,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
// Limited Items
|
||||
HashMap<String, JobLimitedItems> jobLimitedItems = new HashMap<>();
|
||||
Map<String, JobLimitedItems> jobLimitedItems = new HashMap<>();
|
||||
ConfigurationSection limitedItemsSection = jobSection.getConfigurationSection("limitedItems");
|
||||
if (limitedItemsSection != null) {
|
||||
for (String itemKey : limitedItemsSection.getKeys(false)) {
|
||||
@ -1093,10 +1093,11 @@ public class ConfigManager {
|
||||
if (!eachLine.contains("="))
|
||||
continue;
|
||||
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(eachLine.split("=")[0]);
|
||||
String[] split = eachLine.split("=", 2);
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
Integer level = -1;
|
||||
try {
|
||||
level = Integer.parseInt(eachLine.split("=")[1]);
|
||||
level = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
@ -1120,6 +1121,8 @@ public class ConfigManager {
|
||||
job.setMoneyEquation(incomeEquation);
|
||||
job.setXpEquation(expEquation);
|
||||
job.setPointsEquation(pointsEquation);
|
||||
job.setBossbar(bossbar);
|
||||
job.setRejoinCd(rejoinCd);
|
||||
|
||||
if (jobSection.isConfigurationSection("Quests")) {
|
||||
List<Quest> quests = new ArrayList<>();
|
||||
@ -1148,7 +1151,7 @@ public class ConfigManager {
|
||||
if (sqsection.isList("Objectives")) {
|
||||
List<String> list = sqsection.getStringList("Objectives");
|
||||
for (String oneObjective : list) {
|
||||
String[] split = oneObjective.split(";");
|
||||
String[] split = oneObjective.split(";", 3);
|
||||
if (split.length < 2) {
|
||||
log.warning("Job " + jobKey + " has incorrect quest objective (" + oneObjective + ")!");
|
||||
continue;
|
||||
@ -1183,7 +1186,7 @@ public class ConfigManager {
|
||||
quest.addObjective(objective);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
log.warning("Job " + jobKey + " has incorrect quest objective (" + oneObjective + ")!");
|
||||
}
|
||||
}
|
||||
@ -1206,7 +1209,7 @@ public class ConfigManager {
|
||||
quest.setDescription(desc);
|
||||
quest.setRestrictedArea(areas);
|
||||
quests.add(quest);
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
Jobs.consoleMsg("&c[Jobs] Can't load " + one + " quest for " + jobFullName);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1238,7 +1241,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
KeyValues keyValue = null;
|
||||
String[] sep = mat.split(";");
|
||||
String[] sep = mat.split(";", 4);
|
||||
if (sep.length >= 1) {
|
||||
keyValue = getKeyValue(sep[0], actionType, jobKey);
|
||||
}
|
||||
|
@ -39,18 +39,12 @@ import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.CurrencyLimit;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Schedule;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
|
||||
public class GeneralConfigManager {
|
||||
|
||||
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
|
||||
public List<String> FwColors = new ArrayList<>(), DisabledWorldsList = new ArrayList<>();
|
||||
/**
|
||||
* @deprecated use {@link ScheduleManager}
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Schedule> BoostSchedule = new ArrayList<>();
|
||||
|
||||
public final Map<CMIMaterial, Map<Enchantment, Integer>> whiteListedItems = new HashMap<>();
|
||||
private final Map<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
|
||||
@ -484,12 +478,12 @@ public class GeneralConfigManager {
|
||||
String ench = null;
|
||||
|
||||
if (one.contains("=")) {
|
||||
String[] split = one.split("=");
|
||||
String[] split = one.split("=", 2);
|
||||
mName = split[0];
|
||||
ench = split[1];
|
||||
}
|
||||
|
||||
String value = ench != null && ench.contains("-") ? ench.split("-")[1] : null;
|
||||
String value = ench != null && ench.contains("-") ? ench.split("-", 2)[1] : null;
|
||||
if (value != null && ench != null) {
|
||||
ench = ench.substring(0, ench.length() - (value.length() + 1));
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class RestrictedAreaManager {
|
||||
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
|
||||
if (areaSection != null) {
|
||||
for (String areaKey : areaSection.getKeys(false)) {
|
||||
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0d);
|
||||
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier");
|
||||
|
||||
if (conf.isBoolean("restrictedareas." + areaKey + ".WG")) {
|
||||
addNew(new RestrictedArea(areaKey, areaKey, multiplier));
|
||||
@ -204,11 +204,11 @@ public class RestrictedAreaManager {
|
||||
World world = Bukkit.getServer().getWorld(conf.getString("restrictedareas." + areaKey + ".world", ""));
|
||||
if (world == null)
|
||||
continue;
|
||||
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0d), conf.getDouble("restrictedareas." + areaKey
|
||||
+ ".point1.y", 0d), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0d));
|
||||
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x"), conf.getDouble("restrictedareas." + areaKey
|
||||
+ ".point1.y"), conf.getDouble("restrictedareas." + areaKey + ".point1.z"));
|
||||
|
||||
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0d), conf.getDouble("restrictedareas." + areaKey
|
||||
+ ".point2.y", 0d), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0d));
|
||||
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x"), conf.getDouble("restrictedareas." + areaKey
|
||||
+ ".point2.y"), conf.getDouble("restrictedareas." + areaKey + ".point2.z"));
|
||||
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gamingmesh.jobs.config;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -54,11 +53,10 @@ public class ScheduleManager {
|
||||
if (BOOSTSCHEDULE.isEmpty())
|
||||
return false;
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
String currenttime = dateFormat.format(new Date());
|
||||
String currentTime = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
||||
String currentDayName = getWeekDay();
|
||||
|
||||
int current = Integer.parseInt(currenttime.replace(":", ""));
|
||||
int current = Integer.parseInt(currentTime.replace(":", ""));
|
||||
|
||||
for (Schedule one : BOOSTSCHEDULE) {
|
||||
|
||||
|
@ -49,8 +49,8 @@ public class Job {
|
||||
private List<JobCommands> jobCommands;
|
||||
private List<JobConditions> jobConditions;
|
||||
|
||||
private HashMap<String, JobItems> jobItems;
|
||||
private HashMap<String, JobLimitedItems> jobLimitedItems;
|
||||
private Map<String, JobItems> jobItems;
|
||||
private Map<String, JobLimitedItems> jobLimitedItems;
|
||||
|
||||
private String jobName = "N/A";
|
||||
private String fullName = "N/A";
|
||||
@ -93,18 +93,19 @@ public class Job {
|
||||
|
||||
@Deprecated
|
||||
public Job(String jobName, String fullName, String jobShortName, String description, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, HashMap<String, JobItems> jobItems,
|
||||
HashMap<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, Map<String, JobItems> jobItems,
|
||||
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
|
||||
this(jobName, fullName, jobShortName, jobColour, maxExpEquation, displayMethod, maxLevel,
|
||||
vipmaxLevel, maxSlots, jobPermissions, jobCommands, jobConditions, jobItems,
|
||||
jobLimitedItems, cmdOnJoin, cmdOnLeave, guiItem, guiSlot, bossbar, rejoinCD, worldBlacklist);
|
||||
vipmaxLevel, maxSlots, jobPermissions, jobCommands, jobConditions,
|
||||
jobLimitedItems, cmdOnJoin, cmdOnLeave, guiItem, guiSlot, worldBlacklist);
|
||||
|
||||
this.jobItems = jobItems;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Job(String jobName, String fullName, String jobShortName, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, HashMap<String, JobItems> jobItems,
|
||||
HashMap<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions,
|
||||
Map<String, JobLimitedItems> jobLimitedItems, List<String> cmdOnJoin, List<String> cmdOnLeave, ItemStack guiItem, int guiSlot, List<String> worldBlacklist) {
|
||||
this.jobName = jobName == null ? "" : jobName;
|
||||
this.fullName = fullName == null ? "" : fullName;
|
||||
this.jobShortName = jobShortName;
|
||||
@ -117,14 +118,11 @@ public class Job {
|
||||
this.jobPermissions = jobPermissions;
|
||||
this.jobCommands = jobCommands;
|
||||
this.jobConditions = jobConditions;
|
||||
this.jobItems = jobItems;
|
||||
this.jobLimitedItems = jobLimitedItems;
|
||||
this.cmdOnJoin = cmdOnJoin;
|
||||
this.cmdOnLeave = cmdOnLeave;
|
||||
this.guiItem = guiItem;
|
||||
this.guiSlot = guiSlot;
|
||||
this.bossbar = bossbar;
|
||||
this.rejoinCd = rejoinCD;
|
||||
|
||||
if (worldBlacklist != null) {
|
||||
this.worldBlacklist = worldBlacklist;
|
||||
@ -169,7 +167,7 @@ public class Job {
|
||||
}
|
||||
|
||||
public boolean isSame(Job job) {
|
||||
return job != null && (getName().equalsIgnoreCase(job.getName()) || id == job.getId());
|
||||
return job != null && (fullName.equalsIgnoreCase(job.getName()) || id == job.getId());
|
||||
}
|
||||
|
||||
public int getTotalPlayers() {
|
||||
@ -436,7 +434,7 @@ public class Job {
|
||||
* @return Items for this job
|
||||
*/
|
||||
@Deprecated
|
||||
public HashMap<String, JobItems> getItemBonus() {
|
||||
public Map<String, JobItems> getItemBonus() {
|
||||
if (jobItems == null)
|
||||
jobItems = new HashMap<String, JobItems>();
|
||||
return jobItems;
|
||||
@ -451,7 +449,7 @@ public class Job {
|
||||
* Get the limited item nodes for this job
|
||||
* @return Limited items for this job
|
||||
*/
|
||||
public HashMap<String, JobLimitedItems> getLimitedItems() {
|
||||
public Map<String, JobLimitedItems> getLimitedItems() {
|
||||
return jobLimitedItems;
|
||||
}
|
||||
|
||||
|
@ -1214,7 +1214,7 @@ public abstract class JobsDAO {
|
||||
|
||||
job.setId(jobId + 1);
|
||||
|
||||
prestt = conn.prepareStatement("UPDATE `" + getJobsTableName() + "` SET `" + JobsTableFields.jobid.getCollumn() + "` = ? WHERE `" + JobsTableFields.job.getCollumn() + "` = ?;");
|
||||
prestt = conn.prepareStatement("UPDATE `" + getJobsTableName() + "` SET `" + JobsTableFields.job.getCollumn() + "` = ? WHERE `" + JobsTableFields.jobid.getCollumn() + "` = ?;");
|
||||
prestt.setString(1, job.getName());
|
||||
prestt.setInt(2, job.getId());
|
||||
prestt.execute();
|
||||
@ -1308,8 +1308,7 @@ public abstract class JobsDAO {
|
||||
* @return list of all of the names of the jobs the players are part of.
|
||||
*/
|
||||
public synchronized List<JobsDAOData> getAllJobsOffline(String userName) {
|
||||
|
||||
ArrayList<JobsDAOData> jobs = new ArrayList<>();
|
||||
List<JobsDAOData> jobs = new ArrayList<>();
|
||||
|
||||
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(userName);
|
||||
if (info == null)
|
||||
@ -1478,14 +1477,12 @@ public abstract class JobsDAO {
|
||||
return;
|
||||
PreparedStatement prest = null;
|
||||
try {
|
||||
int level = job.getLevel();
|
||||
Double exp = job.getExperience();
|
||||
prest = conn.prepareStatement("INSERT INTO `" + getJobsTableName() + "` (`" + JobsTableFields.userid.getCollumn() + "`, `" + JobsTableFields.jobid.getCollumn()
|
||||
+ "`, `" + JobsTableFields.level.getCollumn() + "`, `" + JobsTableFields.experience.getCollumn() + "`, `" + JobsTableFields.job.getCollumn() + "`) VALUES (?, ?, ?, ?, ?);");
|
||||
prest.setInt(1, jPlayer.getUserId());
|
||||
prest.setInt(2, job.getJob().getId());
|
||||
prest.setInt(3, level);
|
||||
prest.setDouble(4, exp);
|
||||
prest.setInt(3, job.getLevel());
|
||||
prest.setDouble(4, job.getExperience());
|
||||
prest.setString(5, job.getJob().getName());
|
||||
prest.execute();
|
||||
} catch (SQLException e) {
|
||||
@ -1659,7 +1656,6 @@ public abstract class JobsDAO {
|
||||
return;
|
||||
PreparedStatement prest = null;
|
||||
try {
|
||||
int level = jp.getLevel();
|
||||
Double exp = jp.getExperience();
|
||||
prest = conn.prepareStatement("INSERT INTO `" + DBTables.ArchiveTable.getTableName() + "` (`" + ArchiveTableFields.userid.getCollumn()
|
||||
+ "`, `" + ArchiveTableFields.jobid.getCollumn()
|
||||
@ -1670,7 +1666,7 @@ public abstract class JobsDAO {
|
||||
+ "`) VALUES (?, ?, ?, ?, ?, ?);");
|
||||
prest.setInt(1, jPlayer.getUserId());
|
||||
prest.setInt(2, job.getId());
|
||||
prest.setInt(3, level);
|
||||
prest.setInt(3, jp.getLevel());
|
||||
prest.setInt(4, exp.intValue());
|
||||
prest.setLong(5, System.currentTimeMillis());
|
||||
prest.setString(6, job.getName());
|
||||
@ -1715,8 +1711,7 @@ public abstract class JobsDAO {
|
||||
if (info == null)
|
||||
continue;
|
||||
|
||||
TopList top = new TopList(info, res.getInt("totallvl"), 0);
|
||||
names.add(top);
|
||||
names.add(new TopList(info, res.getInt("totallvl"), 0));
|
||||
|
||||
if (names.size() >= Jobs.getGCManager().JobsTopAmount * 2)
|
||||
break;
|
||||
@ -1760,8 +1755,7 @@ public abstract class JobsDAO {
|
||||
if (info == null)
|
||||
continue;
|
||||
|
||||
TopList top = new TopList(info, res.getInt(UserTableFields.donequests.getCollumn()), 0);
|
||||
names.add(top);
|
||||
names.add(new TopList(info, res.getInt(UserTableFields.donequests.getCollumn()), 0));
|
||||
|
||||
if (names.size() >= Jobs.getGCManager().JobsTopAmount)
|
||||
break;
|
||||
@ -2322,10 +2316,10 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prestDel = null;
|
||||
ResultSet res = null;
|
||||
|
||||
Long timer = System.currentTimeMillis();
|
||||
long timer = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
Long mark = System.currentTimeMillis() - (Jobs.getGCManager().BlockProtectionDays * 24L * 60L * 60L * 1000L);
|
||||
long mark = System.currentTimeMillis() - (Jobs.getGCManager().BlockProtectionDays * 24L * 60L * 60L * 1000L);
|
||||
prestDel = conn.prepareStatement("DELETE FROM `" + DBTables.BlocksTable.getTableName() + "` WHERE `" + BlockTableFields.recorded.getCollumn() + "` < ? OR `" +
|
||||
BlockTableFields.resets.getCollumn() + "` < ? AND `" + BlockTableFields.resets.getCollumn() + "` > 0;");
|
||||
prestDel.setLong(1, mark);
|
||||
@ -2371,9 +2365,8 @@ public abstract class JobsDAO {
|
||||
bp.setRecorded(res.getLong(BlockTableFields.recorded.getCollumn()));
|
||||
bp.setAction(DBAction.NONE);
|
||||
i++;
|
||||
ii++;
|
||||
|
||||
if (ii >= 100000) {
|
||||
if (ii++ >= 100000) {
|
||||
Jobs.consoleMsg("&6[Jobs] Loading (" + i + ") BP");
|
||||
ii = 0;
|
||||
}
|
||||
@ -2442,7 +2435,6 @@ public abstract class JobsDAO {
|
||||
|
||||
if (i > 0)
|
||||
Jobs.consoleMsg("&e[Jobs] Saved " + i + " new explorer entries.");
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -2473,10 +2465,9 @@ public abstract class JobsDAO {
|
||||
|
||||
for (ExploreRegion worlds : temp.values()) {
|
||||
for (ExploreChunk oneChunk : worlds.getChunks().values()) {
|
||||
if (oneChunk.getDbId() == -1)
|
||||
continue;
|
||||
if (!oneChunk.isUpdated())
|
||||
if (oneChunk.getDbId() == -1 || !oneChunk.isUpdated())
|
||||
continue;
|
||||
|
||||
prest.setString(1, oneChunk.serializeNames());
|
||||
prest.setInt(2, oneChunk.getDbId());
|
||||
prest.addBatch();
|
||||
@ -2541,7 +2532,6 @@ public abstract class JobsDAO {
|
||||
} finally {
|
||||
close(prest2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
@ -2590,7 +2580,7 @@ public abstract class JobsDAO {
|
||||
* @param toplist - toplist by jobs name
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<TopList> toplist(String jobsname) {
|
||||
public List<TopList> toplist(String jobsname) {
|
||||
return toplist(jobsname, 0);
|
||||
}
|
||||
|
||||
@ -2599,8 +2589,8 @@ public abstract class JobsDAO {
|
||||
* @param toplist - toplist by jobs name
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<TopList> toplist(String jobsname, int limit) {
|
||||
ArrayList<TopList> jobs = new ArrayList<>();
|
||||
public List<TopList> toplist(String jobsname, int limit) {
|
||||
List<TopList> jobs = new ArrayList<>();
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null)
|
||||
return jobs;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -9,7 +8,6 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
@ -25,23 +23,19 @@ public class TabComplete implements TabCompleter {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> completionList = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
List<String> temp = new ArrayList<>();
|
||||
|
||||
temp.addAll(Jobs.getCommandManager().getCommands(sender));
|
||||
StringUtil.copyPartialMatches(args[0], temp, completionList);
|
||||
return new ArrayList<>(Jobs.getCommandManager().getCommands(sender));
|
||||
}
|
||||
if (args.length > 1)
|
||||
for (int i = 1; i <= args.length; i++)
|
||||
if (args.length == i + 1) {
|
||||
String partOfCommand = args[i];
|
||||
|
||||
if (!Jobs.getGCManager().getCommandArgs().containsKey(args[0].toLowerCase()))
|
||||
if (args.length > 1) {
|
||||
String first = args[0].toLowerCase();
|
||||
|
||||
for (int i = 1; i <= args.length; i++) {
|
||||
if (args.length == i + 1) {
|
||||
if (!Jobs.getGCManager().getCommandArgs().containsKey(first))
|
||||
break;
|
||||
|
||||
List<String> argsList = Jobs.getGCManager().getCommandArgs().get(args[0].toLowerCase());
|
||||
List<String> argsList = Jobs.getGCManager().getCommandArgs().get(first);
|
||||
if (argsList.size() < i)
|
||||
continue;
|
||||
|
||||
@ -133,10 +127,11 @@ public class TabComplete implements TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
StringUtil.copyPartialMatches(partOfCommand, temp, completionList);
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(completionList);
|
||||
return completionList;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user