mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-18 05:11:32 +01:00
Allow to set bossbar bar colors by jobs
This commit is contained in:
parent
2b14078860
commit
c490e34fc6
@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.BossBarInfo;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
@ -81,7 +82,8 @@ public class BossBarManager {
|
||||
"%jobmaxxp%", jobProg.getMaxExperience());
|
||||
|
||||
if (bar == null) {
|
||||
BarColor color = BarColor.BLUE;
|
||||
BarColor color = getColor(jobProg.getJob());
|
||||
if (color == null) {
|
||||
switch (player.getBossBarInfo().size()) {
|
||||
case 1:
|
||||
color = BarColor.GREEN;
|
||||
@ -101,6 +103,10 @@ public class BossBarManager {
|
||||
case 6:
|
||||
color = BarColor.PURPLE;
|
||||
break;
|
||||
default:
|
||||
color = BarColor.BLUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bar = Bukkit.createBossBar(message, color, BarStyle.SEGMENTED_20);
|
||||
} else
|
||||
@ -144,4 +150,14 @@ public class BossBarManager {
|
||||
}, Jobs.getGCManager().BossBarTimer * 20L));
|
||||
|
||||
}
|
||||
|
||||
private BarColor getColor(Job job) {
|
||||
if (job.getBossbar() == null)
|
||||
return null;
|
||||
for (BarColor color : BarColor.values()) {
|
||||
if (job.getBossbar().equalsIgnoreCase(color.name()))
|
||||
return color;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -49,7 +50,6 @@ import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobPermission;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
|
||||
public class ConfigManager {
|
||||
private Jobs plugin;
|
||||
@ -154,6 +154,16 @@ public class ConfigManager {
|
||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
|
||||
}
|
||||
}
|
||||
|
||||
String bossbar = null;
|
||||
if (jobSection.contains("BossBarColour")) {
|
||||
bossbar = jobSection.getString("BossBarColour", "");
|
||||
if (bossbar == null) {
|
||||
color = ChatColor.WHITE;
|
||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid BossBarColour property.");
|
||||
}
|
||||
}
|
||||
|
||||
DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
|
||||
if (displayMethod == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!");
|
||||
@ -406,7 +416,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem);
|
||||
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar);
|
||||
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
|
||||
|
@ -71,6 +71,7 @@ public class Job {
|
||||
private Double bonus = null;
|
||||
|
||||
private BoostMultiplier boost = new BoostMultiplier();
|
||||
private String bossbar;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -93,7 +94,7 @@ public class Job {
|
||||
*/
|
||||
public Job(String jobName, 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, List<JobItems> jobItems,
|
||||
List<JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem) {
|
||||
List<JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, String bossbar) {
|
||||
this.jobName = jobName;
|
||||
this.jobShortName = jobShortName;
|
||||
this.description = description;
|
||||
@ -111,6 +112,7 @@ public class Job {
|
||||
this.CmdOnJoin = CmdOnJoin;
|
||||
this.CmdOnLeave = CmdOnLeave;
|
||||
this.GUIitem = GUIitem;
|
||||
this.bossbar = bossbar;
|
||||
}
|
||||
|
||||
public void addBoost(CurrencyType type, double Point) {
|
||||
@ -342,4 +344,12 @@ public class Job {
|
||||
public List<JobLimitedItems> getLimitedItems() {
|
||||
return Collections.unmodifiableList(jobLimitedItems);
|
||||
}
|
||||
|
||||
public String getBossbar() {
|
||||
return bossbar;
|
||||
}
|
||||
|
||||
public void setBossbar(String bossbar) {
|
||||
this.bossbar = bossbar;
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ public class BufferedEconomy {
|
||||
try {
|
||||
// Action bar stuff
|
||||
Jobs.getActionBar().ShowActionBar(payment);
|
||||
if (payment.getOfflinePlayer().isOnline()) {
|
||||
if (payment.getOfflinePlayer().isOnline() && Jobs.getActionBar().getVersion() > 1900) {
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName());
|
||||
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ public class ActionBar {
|
||||
cleanVersion = 1920;
|
||||
if (version.contains("v1_10_R1"))
|
||||
cleanVersion = 11010;
|
||||
if (version.contains("v1_11_R1"))
|
||||
cleanVersion = 11110;
|
||||
}
|
||||
|
||||
if (cleanVersion < 1400)
|
||||
|
Loading…
Reference in New Issue
Block a user