1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 07:01:22 +01:00

Option to use old jobs browse look

This commit is contained in:
Zrips 2018-01-23 16:23:48 +02:00
parent 4cb14c3bfc
commit f79526f711
2 changed files with 163 additions and 158 deletions

View File

@ -1,7 +1,6 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -13,7 +12,6 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.PageInfo; import com.gamingmesh.jobs.stuff.PageInfo;
import com.gamingmesh.jobs.stuff.RawMessage; import com.gamingmesh.jobs.stuff.RawMessage;
@ -23,192 +21,196 @@ public class browse implements Cmd {
@JobCommand(200) @JobCommand(200)
public boolean perform(Jobs plugin, CommandSender sender, final String[] args) { public boolean perform(Jobs plugin, CommandSender sender, final String[] args) {
List<Job> jobList = new ArrayList<Job>(Jobs.getJobs()); if (Jobs.getGCManager().BrowseUseNewLook) {
List<Job> jobList = new ArrayList<Job>(Jobs.getJobs());
if (jobList.size() == 0) { if (jobList.size() == 0) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
return true;
}
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
Inventory inv = null;
try {
inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender);
} catch (Exception e) {
((Player) sender).closeInventory();
Jobs.getGUIManager().GuiList.remove(((Player) sender).getName());
return true; return true;
} }
if (inv == null)
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
Inventory inv = null;
try {
inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender);
} catch (Exception e) {
((Player) sender).closeInventory();
Jobs.getGUIManager().GuiList.remove(((Player) sender).getName());
return true;
}
if (inv == null)
return true;
((Player) sender).openInventory(inv);
return true; return true;
((Player) sender).openInventory(inv); }
return true;
}
int page = 1; int page = 1;
Job j = null; Job j = null;
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()));
continue; continue;
} catch (Exception e) { } catch (Exception e) {
}
}
if (one.startsWith("-j:")) {
try {
j = Jobs.getJob(one.substring("-j:".length()));
continue;
} catch (Exception e) {
}
} }
} }
if (one.startsWith("-j:")) {
try {
j = Jobs.getJob(one.substring("-j:".length()));
continue;
} catch (Exception e) {
}
}
}
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()) {
hoverMsg += one.getDescription().replace("/n", "");
}
if (one.getMaxLevel(sender) > 0) {
if (!hoverMsg.isEmpty())
hoverMsg += " \n";
hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", one.getMaxLevel(sender));
}
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 ((int) (one.getBonus() * 100) < 0)
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (one.getBonus() * 100) * -1);
else
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (one.getBonus() * 100));
}
if (!one.getDescription().isEmpty()) {
hoverMsg += one.getDescription().replace("/n", "");
}
if (one.getMaxLevel(sender) > 0) {
if (!hoverMsg.isEmpty()) if (!hoverMsg.isEmpty())
hoverMsg += " \n"; hoverMsg += " \n";
hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", one.getMaxLevel(sender)); hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click");
rm.add(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), "[jobname]", one.getName()),
hoverMsg, "jobs browse -j:" + one.getName());
rm.show(sender);
}
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs browse", "-p:");
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
if (j.getMaxLevel(sender) > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender)));
} }
if (Jobs.getGCManager().ShowTotalWorkers) { if (Jobs.getGCManager().ShowTotalWorkers) {
if (!hoverMsg.isEmpty()) sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
hoverMsg += " \n";
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 ((int) (j.getBonus() * 100) < 0)
hoverMsg += " \n"; sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1));
if ((int) (one.getBonus() * 100) < 0)
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (one.getBonus() * 100) * -1);
else else
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (one.getBonus() * 100)); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
} }
if (!hoverMsg.isEmpty()) if (!j.getFullDescription().isEmpty())
hoverMsg += " \n"; for (String one : j.getFullDescription()) {
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); sender.sendMessage(one);
}
rm.add(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), "[jobname]", one.getName()),
hoverMsg, "jobs browse -j:" + one.getName());
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.browse.output.detailed"),
Jobs.getLanguage().getMessage("command.browse.output.detailed"),
"jobs info " + j.getName());
rm.show(sender);
rm.clear();
rm.add(Jobs.getLanguage().getMessage("command.browse.output.chooseJob"),
Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover"),
"jobs join " + j.getName() + " -needConfirmation");
rm.show(sender); rm.show(sender);
} }
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs browse", "-p:");
} else { } else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); ArrayList<String> lines = new ArrayList<String>();
for (Job job : Jobs.getJobs()) {
if (j.getMaxLevel(sender) > 0) { if (Jobs.getGCManager().getHideJobsWithoutPermission()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender))); if (!Jobs.getCommandManager().hasJobPermission(sender, job))
} continue;
}
if (Jobs.getGCManager().ShowTotalWorkers) { StringBuilder builder = new StringBuilder();
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); builder.append(" ");
builder.append(job.getChatColor().toString());
} builder.append(job.getName());
if (job.getMaxLevel(sender) > 0) {
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { builder.append(ChatColor.WHITE.toString());
if ((int) (j.getBonus() * 100) < 0) builder.append(Jobs.getLanguage().getMessage("command.info.help.max"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1)); builder.append(job.getMaxLevel(sender));
else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
}
if (!j.getFullDescription().isEmpty())
for (String one : j.getFullDescription()) {
sender.sendMessage(one);
} }
RawMessage rm = new RawMessage(); if (Jobs.getGCManager().ShowTotalWorkers)
rm.add(Jobs.getLanguage().getMessage("command.browse.output.detailed"), builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
Jobs.getLanguage().getMessage("command.browse.output.detailed"),
"jobs info " + j.getName()); if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
rm.show(sender); if (job.getBonus() < 0)
rm.clear(); builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
rm.add(Jobs.getLanguage().getMessage("command.browse.output.chooseJob"), else
Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover"), builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
"jobs join " + j.getName() + " -needConfirmation");
rm.show(sender); lines.add(builder.toString());
if (!job.getDescription().isEmpty()) {
lines.add(" - " + job.getDescription().replace("/n", ""));
}
}
if (lines.size() == 0) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
return true;
}
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
Inventory inv = null;
try {
inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender);
} catch (Exception e) {
((Player) sender).closeInventory();
Jobs.getGUIManager().GuiList.remove(((Player) sender).getName());
return true;
}
if (inv == null)
return true;
((Player) sender).openInventory(inv);
}
if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
for (String line : lines) {
sender.sendMessage(line);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
}
} }
//
// ArrayList<String> lines = new ArrayList<String>();
// 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());
// if (job.getMaxLevel(sender) > 0) {
// builder.append(ChatColor.WHITE.toString());
// builder.append(Jobs.getLanguage().getMessage("command.info.help.max"));
// builder.append(job.getMaxLevel(sender));
// }
//
// if (Jobs.getGCManager().ShowTotalWorkers)
// builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
//
// if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
// if (job.getBonus() < 0)
// builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
// else
// builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
//
// lines.add(builder.toString());
// if (!job.getDescription().isEmpty()) {
// lines.add(" - " + job.getDescription().replace("/n", ""));
// }
// }
//
// if (lines.size() == 0) {
// sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
// return true;
// }
//
// if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
//
// Inventory inv = null;
// try {
// inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender);
// } catch (Exception e) {
// ((Player) sender).closeInventory();
// Jobs.getGUIManager().GuiList.remove(((Player) sender).getName());
// return true;
// }
// if (inv == null)
// return true;
//
// ((Player) sender).openInventory(inv);
//
// }
//
// if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
// sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
// for (String line : lines) {
// sender.sendMessage(line);
// }
// sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
// }
return true; return true;
} }
} }

View File

@ -80,7 +80,8 @@ public class GeneralConfigManager {
public boolean PayForRenaming, PayForEachCraft, SignsEnabled, public boolean PayForRenaming, PayForEachCraft, SignsEnabled,
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse,
EnableAnounceMessage, useSilkTouchProtection, UseCustomNames, EnableAnounceMessage, useSilkTouchProtection, UseCustomNames,
UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps; UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
BrowseUseNewLook;
public int globalblocktimer, CowMilkingTimer, public int globalblocktimer, CowMilkingTimer,
CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval;
public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier; public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier;
@ -871,6 +872,8 @@ public class GeneralConfigManager {
c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show penalty and bonus in jobs browse window. Only works if this feature is enabled"); c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show penalty and bonus in jobs browse window. Only works if this feature is enabled");
ShowPenaltyBonus = c.get("JobsBrowse.ShowPenaltyBonus", true); ShowPenaltyBonus = c.get("JobsBrowse.ShowPenaltyBonus", true);
c.getW().addComment("JobsBrowse.UseNewLook", "Defines if you want to use new /jobs browse look or old one");
BrowseUseNewLook = c.get("JobsBrowse.UseNewLook", true);
c.getW().addComment("JobsBrowse.AmountToShow", "Defines amount of jobs to be shown in one page for /jobs browse"); c.getW().addComment("JobsBrowse.AmountToShow", "Defines amount of jobs to be shown in one page for /jobs browse");
BrowseAmountToShow = c.get("JobsBrowse.AmountToShow", 5); BrowseAmountToShow = c.get("JobsBrowse.AmountToShow", 5);