1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Joined job will glow in browse window

This commit is contained in:
Zrips 2023-02-10 15:21:44 +02:00
parent b620dd2bd9
commit 233b234858
6 changed files with 225 additions and 219 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId> <groupId>Jobs</groupId>
<artifactId>jobs</artifactId> <artifactId>jobs</artifactId>
<version>5.1.0.0</version> <version>5.1.2.0</version>
<name>Jobs</name> <name>Jobs</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>

View File

@ -162,7 +162,7 @@ public class GuiManager {
guiItem.setItemMeta(meta); guiItem.setItemMeta(meta);
gui.addButton(new CMIGuiButton(job.getGuiSlot() >= 0 ? job.getGuiSlot() : pos, guiItem) { CMIGuiButton button = new CMIGuiButton(job.getGuiSlot() >= 0 ? job.getGuiSlot() : pos, guiItem) {
@Override @Override
public void click(GUIClickType type) { public void click(GUIClickType type) {
@ -202,7 +202,13 @@ public class GuiManager {
break; break;
} }
} }
}); };
if (jPlayer.isInJob(job)) {
button.setGlowing();
}
gui.addButton(button);
i++; i++;
} }

View File

@ -18,253 +18,253 @@ public class browse implements Cmd {
@Override @Override
public boolean perform(Jobs plugin, CommandSender sender, final String[] args) { public boolean perform(Jobs plugin, CommandSender sender, final String[] args) {
boolean senderIsPlayer = sender instanceof Player; boolean senderIsPlayer = sender instanceof Player;
if (Jobs.getGCManager().BrowseUseNewLook) { if (Jobs.getGCManager().BrowseUseNewLook) {
if (Jobs.getJobs().isEmpty()) { if (Jobs.getJobs().isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
return true; return true;
} }
List<Job> jobList = new ArrayList<>(Jobs.getJobs()); List<Job> jobList = new ArrayList<>(Jobs.getJobs());
if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) { if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
try { try {
plugin.getGUIManager().openJobsBrowseGUI((Player) sender); plugin.getGUIManager().openJobsBrowseGUI((Player) sender);
} catch (Throwable e) { } catch (Throwable e) {
((Player) sender).closeInventory(); ((Player) sender).closeInventory();
} }
return true; return true;
} }
int page = 1; int page = 1;
if (senderIsPlayer) { if (senderIsPlayer) {
for (String one : args) { for (String one : args) {
if (one.startsWith("-p:")) { if (one.startsWith("-p:")) {
try { try {
page = Integer.parseInt(one.substring("-p:".length())); page = Integer.parseInt(one.substring("-p:".length()));
} catch (Exception e) { } catch (Exception e) {
} }
} }
} }
} }
Job j = null; Job j = null;
for (String one : args) { for (String one : args) {
if (one.startsWith("-j:")) { if (one.startsWith("-j:")) {
j = Jobs.getJob(one.substring("-j:".length())); j = Jobs.getJob(one.substring("-j:".length()));
continue; continue;
} }
} }
if (senderIsPlayer) { if (senderIsPlayer) {
if (j == null) { if (j == null) {
PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page); PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size())); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size()));
for (Job one : jobList) { for (Job one : jobList) {
if (!pi.isEntryOk()) if (!pi.isEntryOk())
continue; continue;
if (pi.isBreak()) if (pi.isBreak())
break; break;
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
String hoverMsg = ""; String hoverMsg = "";
if (!one.getDescription().isEmpty()) if (!one.getDescription().isEmpty())
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one.getDescription().replaceAll("/n|\n", "")); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one.getDescription().replaceAll("/n|\n", ""));
else { else {
for (String desc : one.getFullDescription()) { for (String desc : one.getFullDescription()) {
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", desc); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", desc);
} }
} }
int maxLevel = one.getMaxLevel(sender); int maxLevel = one.getMaxLevel(sender);
if (maxLevel > 0) { if (maxLevel > 0) {
if (!hoverMsg.isEmpty()) if (!hoverMsg.isEmpty())
hoverMsg += " \n"; hoverMsg += " \n";
hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel); hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel);
} }
if (Jobs.getGCManager().ShowTotalWorkers) { if (Jobs.getGCManager().ShowTotalWorkers) {
if (!hoverMsg.isEmpty()) if (!hoverMsg.isEmpty())
hoverMsg += " \n"; hoverMsg += " \n";
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", one.getTotalPlayers()); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", one.getTotalPlayers());
} }
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
if (!hoverMsg.isEmpty()) if (!hoverMsg.isEmpty())
hoverMsg += " \n"; hoverMsg += " \n";
int bonus = (int) (one.getBonus() * 100); int bonus = (int) (one.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1);
else else
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus);
} }
if (!hoverMsg.isEmpty()) if (!hoverMsg.isEmpty())
hoverMsg += " \n"; hoverMsg += " \n";
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click");
rm.addText(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), rm.addText(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(),
"[jobname]", one.getName())).addHover(hoverMsg).addCommand("jobs browse -j:" + one.getName()); "[jobname]", one.getName())).addHover(hoverMsg).addCommand("jobs browse -j:" + one.getName());
rm.show(sender); rm.show(sender);
} }
plugin.showPagination(sender, pi, "jobs browse", "-p:"); plugin.showPagination(sender, pi, "jobs browse", "-p:");
} else { } else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
int maxLevel = j.getMaxLevel(sender); int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0) if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel));
if (Jobs.getGCManager().ShowTotalWorkers) if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (j.getBonus() * 100); int bonus = (int) (j.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
else else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
} }
for (String one : j.getFullDescription()) { for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
} }
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.browse.output.detailed")) rm.addText(Jobs.getLanguage().getMessage("command.browse.output.detailed"))
.addHover(Jobs.getLanguage().getMessage("command.browse.output.detailed")).addCommand("jobs info " + j.getName()); .addHover(Jobs.getLanguage().getMessage("command.browse.output.detailed")).addCommand("jobs info " + j.getName());
rm.show(sender); rm.show(sender);
rm.clear(); rm.clear();
rm.addText(Jobs.getLanguage().getMessage("command.browse.output.chooseJob")) rm.addText(Jobs.getLanguage().getMessage("command.browse.output.chooseJob"))
.addHover(Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover")) .addHover(Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover"))
.addCommand("jobs join " + j.getName() + " -needConfirmation").show(sender); .addCommand("jobs join " + j.getName() + " -needConfirmation").show(sender);
} }
} else { } else {
if (j == null) { if (j == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n")); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n"));
for (Job one : jobList) { for (Job one : jobList) {
String msg = ""; String msg = "";
if (!one.getDescription().isEmpty()) if (!one.getDescription().isEmpty())
msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", one.getDescription().replaceAll("/n|\n", "")); msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", one.getDescription().replaceAll("/n|\n", ""));
else { else {
for (String desc : one.getFullDescription()) { for (String desc : one.getFullDescription()) {
msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", desc); msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", desc);
} }
} }
int maxLevel = one.getMaxLevel(sender); int maxLevel = one.getMaxLevel(sender);
if (maxLevel > 0) if (maxLevel > 0)
msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", maxLevel); msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", maxLevel);
if (Jobs.getGCManager().ShowTotalWorkers) if (Jobs.getGCManager().ShowTotalWorkers)
msg += Jobs.getLanguage().getMessage("command.browse.output.console.totalWorkers", "[amount]", one.getTotalPlayers()); msg += Jobs.getLanguage().getMessage("command.browse.output.console.totalWorkers", "[amount]", one.getTotalPlayers());
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (one.getBonus() * 100); int bonus = (int) (one.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
msg += Jobs.getLanguage().getMessage("command.browse.output.console.penalty", "[amount]", bonus * -1); msg += Jobs.getLanguage().getMessage("command.browse.output.console.penalty", "[amount]", bonus * -1);
else else
msg += Jobs.getLanguage().getMessage("command.browse.output.console.bonus", "[amount]", bonus); msg += Jobs.getLanguage().getMessage("command.browse.output.console.bonus", "[amount]", bonus);
} }
msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName()); msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName());
sender.sendMessage(msg); sender.sendMessage(msg);
} }
} else { } else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
int maxLevel = j.getMaxLevel(sender); int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0) if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel));
if (Jobs.getGCManager().ShowTotalWorkers) if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (j.getBonus() * 100); int bonus = (int) (j.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
else else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
} }
for (String one : j.getFullDescription()) { for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
} }
} }
} }
} else { } else {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
for (Job job : Jobs.getJobs()) { for (Job job : Jobs.getJobs()) {
if (Jobs.getGCManager().getHideJobsWithoutPermission()) { if (Jobs.getGCManager().getHideJobsWithoutPermission()) {
if (!Jobs.getCommandManager().hasJobPermission(sender, job)) if (!Jobs.getCommandManager().hasJobPermission(sender, job))
continue; continue;
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(" "); builder.append(" ");
builder.append(job.getChatColor().toString()); builder.append(job.getChatColor().toString());
builder.append(job.getName()); builder.append(job.getName());
int maxLevel = job.getMaxLevel(sender); int maxLevel = job.getMaxLevel(sender);
if (maxLevel > 0) { if (maxLevel > 0) {
builder.append(CMIChatColor.WHITE.toString()); builder.append(CMIChatColor.WHITE.toString());
builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); builder.append(Jobs.getLanguage().getMessage("command.info.help.max"));
builder.append(maxLevel); builder.append(maxLevel);
} }
if (Jobs.getGCManager().ShowTotalWorkers) if (Jobs.getGCManager().ShowTotalWorkers)
builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (job.getBonus() * 100); int bonus = (int) (job.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
else else
builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
} }
lines.add(builder.toString()); lines.add(builder.toString());
if (!job.getDescription().isEmpty()) if (!job.getDescription().isEmpty())
lines.add(" - " + job.getDescription().replaceAll("/n|\n", "")); lines.add(" - " + job.getDescription().replaceAll("/n|\n", ""));
else { else {
for (String desc : job.getFullDescription()) { for (String desc : job.getFullDescription()) {
lines.add(" - " + desc); lines.add(" - " + desc);
} }
} }
} }
if (lines.isEmpty()) { if (lines.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
return true; return true;
} }
if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) { if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
try { try {
plugin.getGUIManager().openJobsBrowseGUI((Player) sender); plugin.getGUIManager().openJobsBrowseGUI((Player) sender);
} catch (Throwable e) { } catch (Throwable e) {
((Player) sender).closeInventory(); ((Player) sender).closeInventory();
} }
return true; return true;
} }
if (Jobs.getGCManager().JobsGUIShowChatBrowse) { if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
lines.forEach(sender::sendMessage); lines.forEach(sender::sendMessage);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
} }
} }
return true; return true;
} }
} }

View File

@ -587,7 +587,7 @@ public class LanguageManager {
c.get("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%."); c.get("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%.");
c.get("command.exp.help.info", "Change the player exp for job."); c.get("command.exp.help.info", "Change the player exp for job.");
c.get("command.exp.help.args", "[playername] [jobname] set/add/take [amount]"); c.get("command.exp.help.args", "[playername] [jobname] set/add/take [amount](rand_[min]-[max]) (-s) (-sa)");
Jobs.getGCManager().getCommandArgs().put("exp", Arrays.asList("[playername]", "[jobname]", "set%%add%%take")); Jobs.getGCManager().getCommandArgs().put("exp", Arrays.asList("[playername]", "[jobname]", "set%%add%%take"));
c.get("command.exp.error.nojob", "&cThis player must first join a job."); c.get("command.exp.error.nojob", "&cThis player must first join a job.");
c.get("command.exp.output.target", "&eYour exp was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp."); c.get("command.exp.output.target", "&eYour exp was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp.");

View File

@ -381,7 +381,7 @@ public class JobsPlayer {
boostCounter.put(jobName, counterList); boostCounter.put(jobName, counterList);
return boost; return boost;
} }
private Double getPlayerBoostNew(String jobName, CurrencyType type) { private Double getPlayerBoostNew(String jobName, CurrencyType type) {
Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false); Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false);
Double boost = v1; Double boost = v1;

View File

@ -10,15 +10,15 @@ import uk.antiperson.stackmob.entity.StackEntity;
public class StackMobHandler { public class StackMobHandler {
public boolean isStacked(LivingEntity entity) { public boolean isStacked(LivingEntity entity) {
return getPlugin().getEntityManager().isStackedEntity(entity); return getPlugin().getEntityManager().isStackedEntity(entity);
} }
public Collection<StackEntity> getStackEntities() { public Collection<StackEntity> getStackEntities() {
return getPlugin().getEntityManager().getStackEntities(); return getPlugin().getEntityManager().getStackEntities();
} }
public StackMob getPlugin() { public StackMob getPlugin() {
return JavaPlugin.getPlugin(StackMob.class); return JavaPlugin.getPlugin(StackMob.class);
} }
} }