mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +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.Jobs;
|
||||||
import com.gamingmesh.jobs.container.BossBarInfo;
|
import com.gamingmesh.jobs.container.BossBarInfo;
|
||||||
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
|
||||||
@ -81,26 +82,31 @@ public class BossBarManager {
|
|||||||
"%jobmaxxp%", jobProg.getMaxExperience());
|
"%jobmaxxp%", jobProg.getMaxExperience());
|
||||||
|
|
||||||
if (bar == null) {
|
if (bar == null) {
|
||||||
BarColor color = BarColor.BLUE;
|
BarColor color = getColor(jobProg.getJob());
|
||||||
switch (player.getBossBarInfo().size()) {
|
if (color == null) {
|
||||||
case 1:
|
switch (player.getBossBarInfo().size()) {
|
||||||
color = BarColor.GREEN;
|
case 1:
|
||||||
break;
|
color = BarColor.GREEN;
|
||||||
case 2:
|
break;
|
||||||
color = BarColor.RED;
|
case 2:
|
||||||
break;
|
color = BarColor.RED;
|
||||||
case 3:
|
break;
|
||||||
color = BarColor.WHITE;
|
case 3:
|
||||||
break;
|
color = BarColor.WHITE;
|
||||||
case 4:
|
break;
|
||||||
color = BarColor.YELLOW;
|
case 4:
|
||||||
break;
|
color = BarColor.YELLOW;
|
||||||
case 5:
|
break;
|
||||||
color = BarColor.PINK;
|
case 5:
|
||||||
break;
|
color = BarColor.PINK;
|
||||||
case 6:
|
break;
|
||||||
color = BarColor.PURPLE;
|
case 6:
|
||||||
break;
|
color = BarColor.PURPLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = BarColor.BLUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bar = Bukkit.createBossBar(message, color, BarStyle.SEGMENTED_20);
|
bar = Bukkit.createBossBar(message, color, BarStyle.SEGMENTED_20);
|
||||||
} else
|
} else
|
||||||
@ -144,4 +150,14 @@ public class BossBarManager {
|
|||||||
}, Jobs.getGCManager().BossBarTimer * 20L));
|
}, 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.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
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.container.JobPermission;
|
||||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
@ -154,6 +154,16 @@ public class ConfigManager {
|
|||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
|
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", ""));
|
DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
|
||||||
if (displayMethod == null) {
|
if (displayMethod == null) {
|
||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!");
|
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,
|
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()) {
|
for (ActionType actionType : ActionType.values()) {
|
||||||
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
|
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
|
||||||
|
@ -71,6 +71,7 @@ public class Job {
|
|||||||
private Double bonus = null;
|
private Double bonus = null;
|
||||||
|
|
||||||
private BoostMultiplier boost = new BoostMultiplier();
|
private BoostMultiplier boost = new BoostMultiplier();
|
||||||
|
private String bossbar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -93,7 +94,7 @@ public class Job {
|
|||||||
*/
|
*/
|
||||||
public Job(String jobName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
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,
|
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.jobName = jobName;
|
||||||
this.jobShortName = jobShortName;
|
this.jobShortName = jobShortName;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -111,6 +112,7 @@ public class Job {
|
|||||||
this.CmdOnJoin = CmdOnJoin;
|
this.CmdOnJoin = CmdOnJoin;
|
||||||
this.CmdOnLeave = CmdOnLeave;
|
this.CmdOnLeave = CmdOnLeave;
|
||||||
this.GUIitem = GUIitem;
|
this.GUIitem = GUIitem;
|
||||||
|
this.bossbar = bossbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBoost(CurrencyType type, double Point) {
|
public void addBoost(CurrencyType type, double Point) {
|
||||||
@ -342,4 +344,12 @@ public class Job {
|
|||||||
public List<JobLimitedItems> getLimitedItems() {
|
public List<JobLimitedItems> getLimitedItems() {
|
||||||
return Collections.unmodifiableList(jobLimitedItems);
|
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 {
|
try {
|
||||||
// Action bar stuff
|
// Action bar stuff
|
||||||
Jobs.getActionBar().ShowActionBar(payment);
|
Jobs.getActionBar().ShowActionBar(payment);
|
||||||
if (payment.getOfflinePlayer().isOnline()) {
|
if (payment.getOfflinePlayer().isOnline() && Jobs.getActionBar().getVersion() > 1900) {
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName());
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName());
|
||||||
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,8 @@ public class ActionBar {
|
|||||||
cleanVersion = 1920;
|
cleanVersion = 1920;
|
||||||
if (version.contains("v1_10_R1"))
|
if (version.contains("v1_10_R1"))
|
||||||
cleanVersion = 11010;
|
cleanVersion = 11010;
|
||||||
|
if (version.contains("v1_11_R1"))
|
||||||
|
cleanVersion = 11110;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanVersion < 1400)
|
if (cleanVersion < 1400)
|
||||||
|
Loading…
Reference in New Issue
Block a user