1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 22:13:25 +01:00

Lets allow to disable each job separately in specific worlds

This commit is contained in:
Zrips 2020-03-25 14:08:33 +02:00
parent e4085da71c
commit 843b07b176
4 changed files with 53 additions and 4 deletions

View File

@ -799,9 +799,9 @@ public class Jobs extends JavaPlugin {
getGCManager().reload();
getLanguage().reload();
try {
getConfigManager().reload();
getConfigManager().reload();
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace();
}
getDBManager().getDB().loadAllJobsWorlds();
@ -909,6 +909,10 @@ public class Jobs extends JavaPlugin {
if (noneJob == null)
return;
if (noneJob.isWorldBlackListed(block, ent) || noneJob.isWorldBlackListed(victim))
return;
JobInfo jobinfo = noneJob.getJobInfo(info, 1);
checkDailyQuests(jPlayer, noneJob, info);
@ -1002,6 +1006,10 @@ public class Jobs extends JavaPlugin {
FastPayment.clear();
for (JobProgression prog : progression) {
if (prog.getJob().isWorldBlackListed(block, ent) || prog.getJob().isWorldBlackListed(victim))
return;
int level = prog.getLevel();
JobInfo jobinfo = prog.getJob().getJobInfo(info, level);

View File

@ -874,6 +874,13 @@ public class ConfigManager {
}
}
// Commands
List<String> worldBlacklist = new ArrayList<>();
if(jobSection.isList("world-blacklist")) {
worldBlacklist = jobSection.getStringList("world-blacklist");
}
// Items **OUTDATED** Moved to ItemBoostManager!!
HashMap<String, JobItems> jobItems = new HashMap<>();
ConfigurationSection itemsSection = jobSection.getConfigurationSection("items");
@ -979,7 +986,7 @@ public class ConfigManager {
}
Job job = new Job(jobKey, jobFullName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar, rejoinCd);
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar, rejoinCd, worldBlacklist);
job.setFullDescription(fDescription);
job.setMoneyEquation(incomeEquation);

View File

@ -22,7 +22,9 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -63,6 +65,8 @@ public class Job {
private List<String> fDescription = new ArrayList<>();
private List<String> worldBlacklist = new ArrayList<>();
private List<Quest> quests = new ArrayList<>();
private int maxDailyQuests = 1;
@ -90,7 +94,7 @@ public class Job {
*/
public Job(String jobName, String fullName, String jobShortName, String description, ChatColor 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, String bossbar, Long rejoinCD) {
HashMap<String, JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
this.jobName = jobName;
this.fullName = fullName;
this.jobShortName = jobShortName;
@ -111,6 +115,7 @@ public class Job {
this.GUIitem = GUIitem;
this.bossbar = bossbar;
this.rejoinCd = rejoinCD;
this.worldBlacklist = worldBlacklist;
}
public void addBoost(CurrencyType type, double Point) {
@ -508,4 +513,29 @@ public class Job {
if (id != 0)
Jobs.getJobsIds().put(id, this);
}
public List<String> getWorldBlacklist() {
return worldBlacklist;
}
public boolean isWorldBlackListed(Entity ent) {
return isWorldBlackListed(null, ent);
}
public boolean isWorldBlackListed(Block block) {
return isWorldBlackListed(block, null);
}
public boolean isWorldBlackListed(Block block, Entity ent) {
if (worldBlacklist.isEmpty())
return false;
if (block != null && worldBlacklist.contains(block.getWorld().getName()))
return true;
if (ent != null && worldBlacklist.contains(ent.getWorld().getName()))
return true;
return false;
}
}

View File

@ -526,6 +526,10 @@ Jobs:
- msg [player] Now you can use woodcutter kit!
levelFrom: 150
levelUntil: 150
# World list in which this job will not work. World name should be exact
world-blacklist:
- plotworld
- teamworld
# Getting more money when equipped with specific weapon/tool are wearing armor
items:
# Just name, don't have any impact