mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Lets load the job files
- Removed more synchronized methods - Added slot option to example job to remind users there is sorting
This commit is contained in:
parent
d158059759
commit
1daf097f2e
@ -28,113 +28,112 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
public class GuiManager {
|
||||
|
||||
public void openJobsBrowseGUI(final Player player) {
|
||||
ArrayList<Job> JobsList = new ArrayList<>();
|
||||
ArrayList<Job> jobsList = new ArrayList<>();
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
if (Jobs.getGCManager().getHideJobsWithoutPermission())
|
||||
if (!Jobs.getCommandManager().hasJobPermission(player, job))
|
||||
continue;
|
||||
JobsList.add(job);
|
||||
jobsList.add(job);
|
||||
}
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.pickjob"));
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
|
||||
int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9,
|
||||
neededSlots = JobsList.size() + ((JobsList.size() / Jobs.getGCManager().getJobsGUIGroupAmount())
|
||||
int guiSize = Jobs.getGCManager().getJobsGUIRows() * 9,
|
||||
neededSlots = jobsList.size() + ((jobsList.size() / Jobs.getGCManager().getJobsGUIGroupAmount())
|
||||
* Jobs.getGCManager().getJobsGUISkipAmount()) + Jobs.getGCManager().getJobsGUIStartPosition(),
|
||||
neededRows = (int) Math.ceil(neededSlots / 9D);
|
||||
|
||||
// Resizing GUI in case we have more jobs then we could fit in current setup
|
||||
GuiSize = Jobs.getGCManager().getJobsGUIRows() > neededRows ? GuiSize : neededRows * 9;
|
||||
guiSize = Jobs.getGCManager().getJobsGUIRows() > neededRows ? guiSize : neededRows * 9;
|
||||
|
||||
// Lets avoid oversized GUI
|
||||
GuiSize = GuiSize > 54 ? 54 : GuiSize;
|
||||
if (guiSize > 54) {
|
||||
guiSize = 54;
|
||||
}
|
||||
|
||||
gui.setInvSize(GuiSize);
|
||||
gui.setInvSize(guiSize);
|
||||
|
||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
int i = 0;
|
||||
int pos = Jobs.getGCManager().getJobsGUIStartPosition() - 1;
|
||||
|
||||
// Changing start position to 0 in case we have more jobs then we can fit in current setup
|
||||
pos = JobsList.size() > 28 ? JobsList.size() <= 42 ? 0 : -1 : pos;
|
||||
pos = jobsList.size() > 28 ? jobsList.size() <= 42 ? 0 : -1 : pos;
|
||||
|
||||
int group = 0;
|
||||
main: for (int z = 0; z < JobsList.size(); z++) {
|
||||
main: for (int z = 0; z < jobsList.size(); z++) {
|
||||
group++;
|
||||
|
||||
if (group > Jobs.getGCManager().getJobsGUIGroupAmount()) {
|
||||
group = 1;
|
||||
|
||||
// Only add skip if we can fit all of them in max sized Gui
|
||||
if (JobsList.size() <= 42) {
|
||||
if (jobsList.size() <= 42) {
|
||||
pos += Jobs.getGCManager().getJobsGUISkipAmount();
|
||||
}
|
||||
}
|
||||
|
||||
pos++;
|
||||
|
||||
if (i >= JobsList.size())
|
||||
if (i >= jobsList.size())
|
||||
break main;
|
||||
|
||||
Job job = JobsList.get(i);
|
||||
ArrayList<String> Lore = new ArrayList<>();
|
||||
Job job = jobsList.get(i);
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
|
||||
for (JobProgression onePJob : JPlayer.getJobProgression()) {
|
||||
for (JobProgression onePJob : jPlayer.getJobProgression()) {
|
||||
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName()))
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
|
||||
}
|
||||
|
||||
int maxlevel = job.getMaxLevel(JPlayer);
|
||||
int maxlevel = job.getMaxLevel(jPlayer);
|
||||
if (maxlevel > 0)
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel);
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel);
|
||||
|
||||
if (Jobs.getGCManager().ShowTotalWorkers)
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
|
||||
if (job.getBonus() < 0)
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
|
||||
else
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
|
||||
|
||||
Lore.addAll(Arrays.asList(job.getDescription().split("/n|\\n")));
|
||||
lore.addAll(Arrays.asList(job.getDescription().split("/n|\\n")));
|
||||
|
||||
if (job.getMaxSlots() != null)
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
|
||||
.getUsedSlots(job)) : 0));
|
||||
|
||||
if (Jobs.getGCManager().ShowActionNames) {
|
||||
Lore.add("");
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions"));
|
||||
lore.add("");
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions"));
|
||||
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
List<JobInfo> info = job.getJobInfo(actionType);
|
||||
if (info != null && !info.isEmpty()) {
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Lore.add("");
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick"));
|
||||
if (JPlayer.isInJob(job))
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.middleClick"));
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick"));
|
||||
lore.add("");
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick"));
|
||||
if (jPlayer.isInJob(job))
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.middleClick"));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick"));
|
||||
|
||||
ItemStack GuiItem = job.getGuiItem();
|
||||
ItemMeta meta = GuiItem.getItemMeta();
|
||||
ItemStack guiItem = job.getGuiItem();
|
||||
ItemMeta meta = guiItem.getItemMeta();
|
||||
meta.setDisplayName(job.getNameWithColor());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
meta.setLore(lore);
|
||||
guiItem.setItemMeta(meta);
|
||||
|
||||
int lastPos = pos;
|
||||
if (job.getGuiSlot() >= 0)
|
||||
lastPos = job.getGuiSlot();
|
||||
|
||||
gui.addButton(new CMIGuiButton(lastPos, GuiItem) {
|
||||
int lastPos = job.getGuiSlot() >= 0 ? job.getGuiSlot() : pos;
|
||||
gui.addButton(new CMIGuiButton(lastPos, guiItem) {
|
||||
|
||||
@Override
|
||||
public void click(GUIClickType type) {
|
||||
@ -188,14 +187,13 @@ public class GuiManager {
|
||||
public void openJobsBrowseGUI(Player player, Job job, boolean fromCommand) {
|
||||
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
||||
|
||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(JPlayer, job);
|
||||
JobProgression prog = JPlayer.getJobProgression(job);
|
||||
|
||||
ItemStack GuiItem = job.getGuiItem();
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
||||
JobProgression prog = jPlayer.getJobProgression(job);
|
||||
ItemStack guiItem = job.getGuiItem();
|
||||
|
||||
int level = prog != null ? prog.getLevel() : 1,
|
||||
numjobs = JPlayer.getJobProgression().size(),
|
||||
numjobs = jPlayer.getJobProgression().size(),
|
||||
nextButton = Jobs.getGCManager().getJobsGUINextButton(),
|
||||
backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
||||
|
||||
@ -205,8 +203,8 @@ public class GuiManager {
|
||||
if (info == null || info.isEmpty())
|
||||
continue;
|
||||
|
||||
ArrayList<String> Lore = new ArrayList<>();
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
|
||||
int y = 1;
|
||||
for (int z = 0; z < info.size(); z++) {
|
||||
@ -215,15 +213,15 @@ public class GuiManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
double income = jInfo.getIncome(level, numjobs, JPlayer.maxJobsEquation);
|
||||
double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation);
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = jInfo.getExperience(level, numjobs, JPlayer.maxJobsEquation);
|
||||
double xp = jInfo.getExperience(level, numjobs, jPlayer.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
|
||||
double points = jInfo.getPoints(level, numjobs, JPlayer.maxJobsEquation);
|
||||
double points = jInfo.getPoints(level, numjobs, jPlayer.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
|
||||
|
||||
@ -245,7 +243,7 @@ public class GuiManager {
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor
|
||||
+ String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));
|
||||
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
|
||||
|
||||
if (y >= 10) {
|
||||
y = 1;
|
||||
@ -257,15 +255,15 @@ public class GuiManager {
|
||||
break;
|
||||
}
|
||||
|
||||
ItemMeta meta = GuiItem.getItemMeta();
|
||||
ItemMeta meta = guiItem.getItemMeta();
|
||||
meta.setDisplayName(job.getNameWithColor());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, GuiItem.clone());
|
||||
meta.setLore(lore);
|
||||
guiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, guiItem.clone());
|
||||
|
||||
GuiItem = job.getGuiItem();
|
||||
Lore = new ArrayList<>();
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
guiItem = job.getGuiItem();
|
||||
lore = new ArrayList<>();
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -276,21 +274,21 @@ public class GuiManager {
|
||||
break;
|
||||
}
|
||||
|
||||
ItemMeta meta = GuiItem.getItemMeta();
|
||||
ItemMeta meta = guiItem.getItemMeta();
|
||||
meta.setDisplayName(job.getNameWithColor());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, GuiItem.clone());
|
||||
meta.setLore(lore);
|
||||
guiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, guiItem.clone());
|
||||
i++;
|
||||
}
|
||||
|
||||
int GuiSize = GUIManager.isOpenedGui(player) && GUIManager.getGui(player) != null ?
|
||||
int guiSize = GUIManager.isOpenedGui(player) && GUIManager.getGui(player) != null ?
|
||||
GUIManager.getGui(player).getInvSize().getFields() : Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()));
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
gui.setInvSize(GuiSize);
|
||||
gui.setInvSize(guiSize);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (ItemStack one : tempInv.getContents()) {
|
||||
@ -299,7 +297,7 @@ public class GuiManager {
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < items.size(); i1++) {
|
||||
if (GuiSize == i1 + 1 || i1 == backButton)
|
||||
if (guiSize == i1 + 1 || i1 == backButton)
|
||||
continue;
|
||||
|
||||
gui.addButton(new CMIGuiButton(i1, items.get(i1)));
|
||||
@ -330,7 +328,7 @@ public class GuiManager {
|
||||
List<ActionType> jobsRemained = new ArrayList<>();
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
List<JobInfo> info = job.getJobInfo(actionType);
|
||||
if (info != null && !info.isEmpty() && info.size() <= GuiSize)
|
||||
if (info != null && !info.isEmpty() && info.size() <= guiSize)
|
||||
jobsRemained.add(actionType);
|
||||
}
|
||||
|
||||
@ -349,21 +347,21 @@ public class GuiManager {
|
||||
private void openJobsBrowseGUI(Player player, Job job, List<ActionType> jobsRemained) {
|
||||
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
||||
|
||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(JPlayer, job);
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
||||
|
||||
int numjobs = JPlayer.getJobProgression().size();
|
||||
int level = JPlayer.getJobProgression(job) != null ? JPlayer.getJobProgression(job).getLevel() : 1;
|
||||
int numjobs = jPlayer.getJobProgression().size();
|
||||
int level = jPlayer.getJobProgression(job) != null ? jPlayer.getJobProgression(job).getLevel() : 1;
|
||||
|
||||
ItemStack GuiItem = job.getGuiItem();
|
||||
ItemStack guiItem = job.getGuiItem();
|
||||
int i = 0;
|
||||
for (ActionType actionType : jobsRemained) {
|
||||
List<JobInfo> info = job.getJobInfo(actionType);
|
||||
if (info == null || info.isEmpty())
|
||||
continue;
|
||||
|
||||
ArrayList<String> Lore = new ArrayList<>();
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
|
||||
int y = 1;
|
||||
for (int z = 0; z < info.size(); z++) {
|
||||
@ -372,15 +370,15 @@ public class GuiManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
double income = jInfo.getIncome(level, numjobs, JPlayer.maxJobsEquation);
|
||||
double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation);
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = jInfo.getExperience(level, numjobs, JPlayer.maxJobsEquation);
|
||||
double xp = jInfo.getExperience(level, numjobs, jPlayer.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
|
||||
double points = jInfo.getPoints(level, numjobs, JPlayer.maxJobsEquation);
|
||||
double points = jInfo.getPoints(level, numjobs, jPlayer.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
|
||||
|
||||
@ -402,7 +400,7 @@ public class GuiManager {
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor
|
||||
+ String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));
|
||||
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
|
||||
|
||||
if (y >= 10) {
|
||||
y = 1;
|
||||
@ -414,15 +412,15 @@ public class GuiManager {
|
||||
break;
|
||||
}
|
||||
|
||||
ItemMeta meta = GuiItem.getItemMeta();
|
||||
ItemMeta meta = guiItem.getItemMeta();
|
||||
meta.setDisplayName(job.getNameWithColor());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, GuiItem.clone());
|
||||
meta.setLore(lore);
|
||||
guiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, guiItem.clone());
|
||||
|
||||
GuiItem = job.getGuiItem();
|
||||
Lore = new ArrayList<>();
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
guiItem = job.getGuiItem();
|
||||
lore = new ArrayList<>();
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -433,22 +431,22 @@ public class GuiManager {
|
||||
break;
|
||||
}
|
||||
|
||||
ItemMeta meta = GuiItem.getItemMeta();
|
||||
ItemMeta meta = guiItem.getItemMeta();
|
||||
meta.setDisplayName(job.getNameWithColor());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, GuiItem.clone());
|
||||
meta.setLore(lore);
|
||||
guiItem.setItemMeta(meta);
|
||||
tempInv.setItem(i, guiItem.clone());
|
||||
i++;
|
||||
}
|
||||
|
||||
int GuiSize = GUIManager.isOpenedGui(player) && GUIManager.getGui(player) != null ?
|
||||
int guiSize = GUIManager.isOpenedGui(player) && GUIManager.getGui(player) != null ?
|
||||
GUIManager.getGui(player).getInvSize().getFields() : Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||
int backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()));
|
||||
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
|
||||
gui.setInvSize(GuiSize);
|
||||
gui.setInvSize(guiSize);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (ItemStack one : tempInv.getContents()) {
|
||||
@ -457,7 +455,7 @@ public class GuiManager {
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < items.size(); i1++) {
|
||||
if (GuiSize == i1 + 1 || i1 == backButton)
|
||||
if (guiSize == i1 + 1 || i1 == backButton)
|
||||
continue;
|
||||
|
||||
gui.addButton(new CMIGuiButton(i1, items.get(i1)));
|
||||
|
@ -387,7 +387,7 @@ public class PlayerManager {
|
||||
Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job));
|
||||
jPlayer.setLeftTime(job);
|
||||
|
||||
PerformCommands.PerformCommandsOnJoin(jPlayer, job);
|
||||
PerformCommands.performCommandsOnJoin(jPlayer, job);
|
||||
|
||||
Jobs.takeSlot(job);
|
||||
Jobs.getSignUtil().updateAllSign(job);
|
||||
@ -418,7 +418,7 @@ public class PlayerManager {
|
||||
|
||||
if (!Jobs.getJobsDAO().quitJob(jPlayer, job))
|
||||
return false;
|
||||
PerformCommands.PerformCommandsOnLeave(jPlayer, job);
|
||||
PerformCommands.performCommandsOnLeave(jPlayer, job);
|
||||
Jobs.leaveSlot(job);
|
||||
|
||||
jPlayer.getLeftTimes().remove(jPlayer.getUniqueId());
|
||||
|
@ -96,9 +96,6 @@ public class JobsCommands implements CommandExecutor {
|
||||
if (back)
|
||||
return true;
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
return help(sender, 1);
|
||||
|
||||
return help(sender, 1);
|
||||
}
|
||||
|
||||
@ -129,7 +126,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
protected boolean help(CommandSender sender, int page) {
|
||||
Map<String, Integer> commands = GetCommands(sender);
|
||||
Map<String, Integer> commands = getCommands(sender);
|
||||
if (commands.isEmpty()) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
return true;
|
||||
@ -159,7 +156,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, Integer> GetCommands(CommandSender sender) {
|
||||
public Map<String, Integer> getCommands(CommandSender sender) {
|
||||
Map<String, Integer> temp = new HashMap<>();
|
||||
for (Entry<String, Integer> cmd : commandList.entrySet()) {
|
||||
if (sender instanceof Player && !hasCommandPermission(sender, cmd.getKey()))
|
||||
|
@ -479,6 +479,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
jobFiles.clear();
|
||||
migrateJobs();
|
||||
|
||||
if (jobFiles.isEmpty()) {
|
||||
|
@ -282,7 +282,7 @@ public class GeneralConfigManager {
|
||||
*
|
||||
* loads from Jobs/generalConfig.yml
|
||||
*/
|
||||
private synchronized void loadGeneralSettings() {
|
||||
private void loadGeneralSettings() {
|
||||
c = new ConfigReader("generalConfig.yml");
|
||||
|
||||
c.header(Arrays.asList("General configuration.",
|
||||
|
@ -23,7 +23,7 @@ public class LanguageManager {
|
||||
*
|
||||
* loads from Jobs/locale/messages_en.yml
|
||||
*/
|
||||
synchronized void load() {
|
||||
void load() {
|
||||
// This should be present to copy over default locale files into locale folder if file doesn't exist. Grabs all files from plugin file.
|
||||
languages = new ArrayList<>();
|
||||
try {
|
||||
|
@ -242,7 +242,7 @@ public class NameTranslatorManager {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
synchronized void load() {
|
||||
void load() {
|
||||
String ls = Jobs.getGCManager().localeString;
|
||||
if (ls.isEmpty())
|
||||
return;
|
||||
|
@ -179,7 +179,7 @@ public class RestrictedAreaManager {
|
||||
*
|
||||
* loads from Jobs/restrictedAreas.yml
|
||||
*/
|
||||
public synchronized void load() {
|
||||
public void load() {
|
||||
restrictedAreas.clear();
|
||||
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||
|
@ -17,7 +17,7 @@ public class RestrictedBlockManager {
|
||||
* Method to load the restricted blocks configuration
|
||||
* loads from Jobs/restrictedBlocks.yml
|
||||
*/
|
||||
public synchronized void load() {
|
||||
public void load() {
|
||||
if (!Jobs.getGCManager().useBlockProtection)
|
||||
return;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class TitleManager {
|
||||
*
|
||||
* loads from Jobs/titleConfig.yml
|
||||
*/
|
||||
synchronized void load() {
|
||||
void load() {
|
||||
titles.clear();
|
||||
|
||||
ConfigReader c = new ConfigReader("titleConfig.yml");
|
||||
|
@ -46,10 +46,16 @@ public class ExploreRegion {
|
||||
|
||||
public int getChunkX(short place) {
|
||||
int endX = place % 32;
|
||||
|
||||
if (x < 0)
|
||||
endX = -endX;
|
||||
|
||||
endX = x * 32 + endX;
|
||||
endX = endX < 0 ? endX + 32 : endX;
|
||||
|
||||
if (endX < 0) {
|
||||
endX += 32;
|
||||
}
|
||||
|
||||
return endX;
|
||||
}
|
||||
|
||||
@ -58,7 +64,11 @@ public class ExploreRegion {
|
||||
if (z < 0)
|
||||
endZ = -endZ;
|
||||
endZ = z * 32 + endZ;
|
||||
endZ = endZ < 0 ? endZ + 32 : endZ;
|
||||
|
||||
if (endZ < 0) {
|
||||
endZ += 32;
|
||||
}
|
||||
|
||||
return endZ;
|
||||
}
|
||||
}
|
||||
|
@ -182,8 +182,6 @@ public class BlockOwnerShip {
|
||||
|
||||
f = f2;
|
||||
|
||||
int total = 0;
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
@ -193,6 +191,7 @@ public class BlockOwnerShip {
|
||||
if (isReassignDisabled() || !config.isConfigurationSection(path))
|
||||
return;
|
||||
|
||||
int total = 0;
|
||||
ConfigurationSection section = config.getConfigurationSection(path);
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
@ -242,12 +241,12 @@ public class BlockOwnerShip {
|
||||
|
||||
f.saveDefaultConfig();
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
if (isReassignDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
@ -255,7 +254,6 @@ public class BlockOwnerShip {
|
||||
|
||||
for (Entry<UUID, List<blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
String full = "";
|
||||
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
@ -27,11 +27,7 @@ public class JobsConnection {
|
||||
}
|
||||
|
||||
public synchronized boolean isValid(int timeout) throws SQLException {
|
||||
try {
|
||||
return conn.isValid(timeout);
|
||||
} catch (AbstractMethodError e) {
|
||||
return true;
|
||||
}
|
||||
return conn.isValid(timeout);
|
||||
}
|
||||
|
||||
public synchronized void closeConnection() throws SQLException {
|
||||
|
@ -870,11 +870,9 @@ public abstract class JobsDAO {
|
||||
prestt.execute();
|
||||
|
||||
res2 = prestt.getGeneratedKeys();
|
||||
int id = 0;
|
||||
if (res2.next())
|
||||
id = res2.getInt(1);
|
||||
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, id, uuid, System.currentTimeMillis(), 0));
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, res2.next() ? res2.getInt(1) : 0,
|
||||
uuid, System.currentTimeMillis(), 0));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -896,12 +894,7 @@ public abstract class JobsDAO {
|
||||
prestt.executeUpdate();
|
||||
|
||||
res2 = prestt.getGeneratedKeys();
|
||||
int id = 0;
|
||||
if (res2.next())
|
||||
id = res2.getInt(1);
|
||||
|
||||
Util.addJobsWorld(new JobsWorld(worldName, id));
|
||||
|
||||
Util.addJobsWorld(new JobsWorld(worldName, res2.next() ? res2.getInt(1) : 0));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
@ -135,11 +135,7 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
if (iih.getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
|
||||
if (Jobs.getNms().getItemInMainHand(player).getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()) || !player.hasPermission("jobs.area.select"))
|
||||
@ -164,8 +160,6 @@ public class JobsListener implements Listener {
|
||||
JobsAreaSelectionEvent jobsAreaSelectionEvent = new JobsAreaSelectionEvent(player, Jobs.getSelectionManager().getSelectionCuboid(player));
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsAreaSelectionEvent);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -201,11 +195,9 @@ public class JobsListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||
if (plugin.isEnabled()) {
|
||||
Jobs.getPermissionHandler().recalculatePermissions(Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
@ -9,16 +7,14 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
public class PerformCommands {
|
||||
|
||||
public static void PerformCommandsOnLeave(JobsPlayer jPlayer, Job job) {
|
||||
List<String> cmds = job.getCmdOnLeave();
|
||||
for (String one : cmds) {
|
||||
public static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) {
|
||||
for (String one : job.getCmdOnLeave()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getName()).replace("[jobname]", job.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void PerformCommandsOnJoin(JobsPlayer jPlayer, Job job) {
|
||||
List<String> cmds = job.getCmdOnJoin();
|
||||
for (String one : cmds) {
|
||||
public static void performCommandsOnJoin(JobsPlayer jPlayer, Job job) {
|
||||
for (String one : job.getCmdOnJoin()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getName()).replace("[jobname]", job.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -32,22 +32,18 @@ public class TabComplete implements TabCompleter {
|
||||
String PartOfCommand = args[0];
|
||||
List<String> temp = new ArrayList<>();
|
||||
|
||||
for (String BCmd : Jobs.getCommandManager().GetCommands(sender).keySet()) {
|
||||
temp.add(BCmd);
|
||||
}
|
||||
Jobs.getCommandManager().getCommands(sender).keySet().forEach(temp::add);
|
||||
StringUtil.copyPartialMatches(PartOfCommand, temp, completionList);
|
||||
}
|
||||
if (args.length > 1)
|
||||
for (int i = 1; i <= args.length; i++)
|
||||
if (args.length == i + 1) {
|
||||
|
||||
String PartOfCommand = args[i];
|
||||
|
||||
if (!Jobs.getGCManager().getCommandArgs().containsKey(args[0].toLowerCase()))
|
||||
break;
|
||||
|
||||
List<String> ArgsList = Jobs.getGCManager().getCommandArgs().get(args[0].toLowerCase());
|
||||
|
||||
if (ArgsList.size() < i)
|
||||
continue;
|
||||
|
||||
|
@ -100,6 +100,9 @@ exampleJob:
|
||||
Enchantments:
|
||||
- 'DURABILITY:1'
|
||||
|
||||
# The number of slot where to put this material in gui.
|
||||
slot: 2
|
||||
|
||||
# Defines maximum amount of daily quests player can have from THIS job
|
||||
# This will not have effect on overall quest amount player will have
|
||||
maxDailyQuests: 3
|
||||
|
Loading…
Reference in New Issue
Block a user