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>
<groupId>Jobs</groupId>
<artifactId>jobs</artifactId>
<version>5.1.0.0</version>
<version>5.1.2.0</version>
<name>Jobs</name>
<url>http://maven.apache.org</url>

View File

@ -162,7 +162,7 @@ public class GuiManager {
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
public void click(GUIClickType type) {
@ -202,7 +202,13 @@ public class GuiManager {
break;
}
}
});
};
if (jPlayer.isInJob(job)) {
button.setGlowing();
}
gui.addButton(button);
i++;
}

View File

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

View File

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

View File

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