mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
New daily quests
updated pagination handling updated browse command look updated time conversion from milliseconds
This commit is contained in:
parent
2f9266d19e
commit
54650a2385
@ -71,6 +71,7 @@ import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
@ -78,8 +79,11 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Log;
|
||||
import com.gamingmesh.jobs.container.PlayerInfo;
|
||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||
import com.gamingmesh.jobs.dao.*;
|
||||
import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.dao.JobsClassLoader;
|
||||
import com.gamingmesh.jobs.dao.JobsDAO;
|
||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||
import com.gamingmesh.jobs.dao.JobsManager;
|
||||
import com.gamingmesh.jobs.economy.BufferedEconomy;
|
||||
import com.gamingmesh.jobs.economy.BufferedPayment;
|
||||
import com.gamingmesh.jobs.economy.Economy;
|
||||
@ -91,11 +95,11 @@ import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
|
||||
@ -852,6 +856,17 @@ public class Jobs extends JavaPlugin {
|
||||
this.setEnabled(false);
|
||||
}
|
||||
|
||||
private static void checkDailyQuests(JobsPlayer jPlayer, JobProgression prog, ActionInfo info) {
|
||||
if (!prog.getJob().getQuests().isEmpty()) {
|
||||
List<QuestProgression> q = jPlayer.getQuestProgressions(prog.getJob(), info.getType());
|
||||
for (QuestProgression one : q) {
|
||||
if (one != null) {
|
||||
one.processQuest(jPlayer, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performed an action
|
||||
*
|
||||
@ -966,6 +981,9 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
if (jobinfo == null)
|
||||
continue;
|
||||
|
||||
checkDailyQuests(jPlayer, prog, info);
|
||||
|
||||
Double income = jobinfo.getIncome(level, numjobs);
|
||||
Double pointAmount = jobinfo.getPoints(level, numjobs);
|
||||
Double expAmount = jobinfo.getExperience(level, numjobs);
|
||||
@ -1288,25 +1306,28 @@ public class Jobs extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void ShowPagination(CommandSender sender, int pageCount, int CurrentPage, String cmd) {
|
||||
ShowPagination(sender, pageCount, CurrentPage, cmd, null);
|
||||
}
|
||||
|
||||
public void ShowPagination(CommandSender sender, int pageCount, int CurrentPage, String cmd, String pagePref) {
|
||||
if (!(sender instanceof Player))
|
||||
return;
|
||||
if (!cmd.startsWith("/"))
|
||||
cmd = "/" + cmd;
|
||||
// String separator = Jobs.getLanguage().getMessage("command.help.output.fliperSimbols");
|
||||
|
||||
if (pageCount == 1)
|
||||
return;
|
||||
|
||||
String pagePrefix = pagePref == null ? "" : pagePref;
|
||||
int NextPage = CurrentPage + 1;
|
||||
NextPage = CurrentPage < pageCount ? NextPage : CurrentPage;
|
||||
int Prevpage = CurrentPage - 1;
|
||||
Prevpage = CurrentPage > 1 ? Prevpage : CurrentPage;
|
||||
|
||||
RawMessage rm = new RawMessage();
|
||||
rm.add((CurrentPage > 1 ? Jobs.getLanguage().getMessage("command.help.output.prev") : Jobs.getLanguage().getMessage("command.help.output.prevOff")), CurrentPage > 1 ? "<<<" : null, CurrentPage > 1
|
||||
? cmd + " " + Prevpage : null);
|
||||
rm.add(pageCount > CurrentPage ? Jobs.getLanguage().getMessage("command.help.output.next") : Jobs.getLanguage().getMessage("command.help.output.nextOff"), pageCount > CurrentPage ? ">>>" : null,
|
||||
pageCount > CurrentPage ? cmd + " " + NextPage : null);
|
||||
rm.add((CurrentPage > 1 ? Jobs.getLanguage().getMessage("command.help.output.prevPage") : Jobs.getLanguage().getMessage("command.help.output.prevPageOff")),
|
||||
CurrentPage > 1 ? "<<<" : null, CurrentPage > 1 ? cmd + " " + pagePrefix + Prevpage : null);
|
||||
rm.add(Jobs.getLanguage().getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount));
|
||||
rm.add(pageCount > CurrentPage ? Jobs.getLanguage().getMessage("command.help.output.nextPage") : Jobs.getLanguage().getMessage("command.help.output.nextPageOff"),
|
||||
pageCount > CurrentPage ? ">>>" : null, pageCount > CurrentPage ? cmd + " " + pagePrefix + NextPage : null);
|
||||
if (pageCount != 0)
|
||||
rm.show(sender);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.economy.PointsData;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||
|
||||
public class PlayerManager {
|
||||
@ -299,6 +300,7 @@ public class PlayerManager {
|
||||
JobsPlayer jPlayer = new JobsPlayer(info.getName(), null);
|
||||
jPlayer.setPlayerUUID(info.getUuid());
|
||||
jPlayer.setUserId(info.getID());
|
||||
jPlayer.setDoneQuests(info.getQuestsDone());
|
||||
|
||||
if (jobs != null)
|
||||
for (JobsDAOData jobdata : jobs) {
|
||||
|
@ -35,6 +35,8 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
|
||||
public class JobsCommands implements CommandExecutor {
|
||||
@ -172,44 +174,24 @@ public class JobsCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
commands = sort(commands);
|
||||
int amountToShow = 7;
|
||||
int start = page * amountToShow - amountToShow;
|
||||
int end = page * amountToShow;
|
||||
int TotalPages = commands.size() / amountToShow;
|
||||
if (((commands.size() * 1.0) / (amountToShow * 1.0)) - TotalPages > 0)
|
||||
TotalPages++;
|
||||
if (start >= commands.size()) {
|
||||
start = page * amountToShow;
|
||||
end = start + amountToShow;
|
||||
}
|
||||
|
||||
if (page > TotalPages || page < 1) {
|
||||
PageInfo pi = new PageInfo(7, commands.size(), page);
|
||||
|
||||
if (page > pi.getTotalPages() || page < 1) {
|
||||
Jobs.getActionBar().send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.title"));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.page", "[1]", page, "[2]", TotalPages));
|
||||
|
||||
int i = -1;
|
||||
for (Entry<String, Integer> one : commands.entrySet()) {
|
||||
i++;
|
||||
if (i < start)
|
||||
if (!pi.isEntryOk())
|
||||
continue;
|
||||
if (i >= end)
|
||||
if (pi.isBreak())
|
||||
break;
|
||||
sender.sendMessage(getUsage(one.getKey()) + " - " + Jobs.getLanguage().getMessage("command." + one.getKey() + ".help.info"));
|
||||
}
|
||||
|
||||
String prevCmd = "/" + label + " ? " + (page - 1);
|
||||
String prev = "[\"\",{\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\""
|
||||
+ prevCmd
|
||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + "<<<" + "\"}]}}}";
|
||||
String nextCmd = "/" + label + " ? " + (page + 1);
|
||||
String next = " {\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + nextCmd
|
||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + ">>>" + "\"}]}}}]";
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + prev + "," + next);
|
||||
plugin.ShowPagination(sender, pi.getTotalPages(), page, label + " ?");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -382,7 +364,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
type = type.toLowerCase();
|
||||
}
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
List<String> message = new ArrayList<String>();
|
||||
|
||||
int showAllTypes = 1;
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
@ -393,105 +375,64 @@ public class JobsCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (job.getBoost().get(CurrencyType.EXP) != 0D)
|
||||
message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.expboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.EXP)) + 1) + "\n");
|
||||
message.add(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.expboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.EXP)) + 1));
|
||||
|
||||
if (job.getBoost().get(CurrencyType.MONEY) != 0D)
|
||||
message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.moneyboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.MONEY)) + 1) + "\n");
|
||||
message.add(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.moneyboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.MONEY)) + 1));
|
||||
|
||||
if (job.getBoost().get(CurrencyType.POINTS) != 0D)
|
||||
message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.pointboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.POINTS)) + 1) + "\n");
|
||||
message.add(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.pointboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.POINTS)) + 1));
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment)
|
||||
if (job.getBonus() < 0)
|
||||
message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.info.help.penalty", "[penalty]", (int) (job.getBonus() * 100) / 100.0 * -1)
|
||||
+ "\n");
|
||||
else
|
||||
message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.info.help.bonus", "[bonus]", (int) (job.getBonus() * 100) / 100.0) + "\n");
|
||||
if (Jobs.getGCManager().useDynamicPayment) {
|
||||
if ((int) (job.getBonus() * 100) / 100.0 != 0) {
|
||||
if ((int) (job.getBonus() * 100) / 100.0 < 0) {
|
||||
message.add(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.info.help.penalty", "[penalty]", (int) (job.getBonus() * 100) / 100.0 * -1));
|
||||
} else {
|
||||
message.add(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.info.help.bonus", "[bonus]", (int) (job.getBonus() * 100) / 100.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
if (showAllTypes == 1 || type.startsWith(actionType.getName().toLowerCase())) {
|
||||
List<JobInfo> info = job.getJobInfo(actionType);
|
||||
if (info != null && !info.isEmpty()) {
|
||||
message.append(jobInfoMessage(player, job, actionType));
|
||||
String m = jobInfoMessage(player, job, actionType);
|
||||
if (m.contains("\n"))
|
||||
message.addAll(Arrays.asList(m.split("\n")));
|
||||
else
|
||||
message.add(m);
|
||||
} else if (showAllTypes == 0) {
|
||||
String myMessage = Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none");
|
||||
myMessage = myMessage.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
|
||||
message.append(myMessage);
|
||||
message.add(myMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder message2 = new StringBuilder();
|
||||
int perPage = 20;
|
||||
int start = (page - 1) * perPage;
|
||||
int end = start + perPage;
|
||||
int pagecount = (int) Math.ceil((double) message.toString().split("\n").length / (double) perPage);
|
||||
if (pagecount == 0)
|
||||
pagecount = 1;
|
||||
if (page > pagecount) {
|
||||
player.getPlayer().sendMessage("Invalid page");
|
||||
PageInfo pi = new PageInfo(15, message.size(), page);
|
||||
|
||||
if (page > pi.getTotalPages()) {
|
||||
player.getPlayer().sendMessage(Jobs.getLanguage().getMessage("general.info.invalidPage"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.toString().split("\n").length > perPage && sender instanceof Player) {
|
||||
int i = 0;
|
||||
for (String one : message.toString().split("\n")) {
|
||||
i++;
|
||||
if (i <= start)
|
||||
continue;
|
||||
if (i > end)
|
||||
break;
|
||||
|
||||
message2.append(one);
|
||||
message2.append("\n");
|
||||
}
|
||||
message = message2;
|
||||
boolean isPlayer = sender instanceof Player;
|
||||
for (String one : message) {
|
||||
if (isPlayer && !pi.isEntryOk())
|
||||
continue;
|
||||
if (isPlayer && pi.isBreak())
|
||||
break;
|
||||
sender.sendMessage(one);
|
||||
}
|
||||
|
||||
sender.sendMessage(message.toString().split("\n"));
|
||||
|
||||
String t = type == "" ? "" : " " + type;
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender.getName().equalsIgnoreCase(player.getUserName()))
|
||||
ShowPagination(sender.getName(), pagecount, page, "jobs info " + job.getName() + t);
|
||||
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs info " + job.getName() + t);
|
||||
else
|
||||
ShowPagination(sender.getName(), pagecount, page, "jobs playerinfo " + player.getUserName() + " " + job.getName() + t);
|
||||
}
|
||||
|
||||
public static void ShowPagination(String target, int pageCount, int CurrentPage, String cmd) {
|
||||
if (target.equalsIgnoreCase("console"))
|
||||
return;
|
||||
// String separator = ChatColor.GOLD + "";
|
||||
// String simbol = "\u25AC";
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// separator += simbol;
|
||||
// }
|
||||
|
||||
if (pageCount == 1)
|
||||
return;
|
||||
|
||||
int NextPage = CurrentPage + 1;
|
||||
NextPage = CurrentPage < pageCount ? NextPage : CurrentPage;
|
||||
int Prevpage = CurrentPage - 1;
|
||||
Prevpage = CurrentPage > 1 ? Prevpage : CurrentPage;
|
||||
|
||||
String prevCmd = "/" + cmd + " " + Prevpage;
|
||||
String prev = "\"\",{\"text\":\" " + Jobs.getLanguage().getMessage("command.help.output.prev")
|
||||
+ "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + prevCmd
|
||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + "<<<" + "\"}]}}}";
|
||||
String nextCmd = "/" + cmd + " " + NextPage;
|
||||
String next = " {\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.next") + " "
|
||||
+ "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\""
|
||||
+ nextCmd + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + ">>>" + "\"}]}}}";
|
||||
|
||||
if (CurrentPage >= pageCount)
|
||||
next = "{\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.next") + " \"}";
|
||||
|
||||
if (CurrentPage <= 1)
|
||||
prev = "{\"text\":\" " + Jobs.getLanguage().getMessage("command.help.output.prev") + "\"}";
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + target + " [" + prev + "," + next + "]");
|
||||
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs playerinfo " + player.getUserName() + " " + job.getName() + t);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,51 +13,24 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
|
||||
public class browse implements Cmd {
|
||||
|
||||
@Override
|
||||
@JobCommand(200)
|
||||
public boolean perform(Jobs plugin, CommandSender sender, final String[] args) {
|
||||
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()));
|
||||
List<Job> jobList = new ArrayList<Job>(Jobs.getJobs());
|
||||
|
||||
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) {
|
||||
if (jobList.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);
|
||||
@ -66,18 +41,174 @@ public class browse implements Cmd {
|
||||
}
|
||||
if (inv == null)
|
||||
return true;
|
||||
|
||||
((Player) sender).openInventory(inv);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
|
||||
for (String line : lines) {
|
||||
sender.sendMessage(line);
|
||||
int page = 1;
|
||||
Job j = null;
|
||||
for (String one : args) {
|
||||
if (one.startsWith("-p:")) {
|
||||
try {
|
||||
page = Integer.parseInt(one.substring("-p:".length()));
|
||||
continue;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (one.startsWith("-j:")) {
|
||||
try {
|
||||
j = Jobs.getJob(one.substring("-j:".length()));
|
||||
continue;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
|
||||
}
|
||||
|
||||
if (j == null) {
|
||||
PageInfo pi = new PageInfo(5, 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();
|
||||
|
||||
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 (!hoverMsg.isEmpty())
|
||||
hoverMsg += " \n";
|
||||
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) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
|
||||
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
if ((int) (j.getBonus() * 100) < 0)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1));
|
||||
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();
|
||||
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);
|
||||
}
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
@ -11,6 +14,7 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
|
||||
public class join implements Cmd {
|
||||
|
||||
@ -22,27 +26,13 @@ public class join implements Cmd {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length != 1 && args.length != 0) {
|
||||
if (args.length != 1 && args.length != 0 && args.length != 2) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "join");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnJoin) {
|
||||
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);
|
||||
} else
|
||||
return false;
|
||||
Bukkit.dispatchCommand(sender, "jobs browse");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -85,6 +75,13 @@ public class join implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) {
|
||||
RawMessage rm = new RawMessage();
|
||||
rm.add(Jobs.getLanguage().getMessage("command.join.confirm"), Jobs.getLanguage().getMessage("command.join.confirm"), "jobs join " + job.getName());
|
||||
rm.show(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
JobProgression ajp = jPlayer.getArchivedJobProgression(job);
|
||||
if (ajp != null) {
|
||||
if (!ajp.canRejoin()) {
|
||||
|
106
src/main/java/com/gamingmesh/jobs/commands/list/quests.java
Normal file
106
src/main/java/com/gamingmesh/jobs/commands/list/quests.java
Normal file
@ -0,0 +1,106 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
public class quests implements Cmd {
|
||||
|
||||
@Override
|
||||
@JobCommand(400)
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
JobsPlayer jPlayer = null;
|
||||
|
||||
if (args.length >= 1 && args[0].equals("next")) {
|
||||
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
jPlayer.resetQuests();
|
||||
} else {
|
||||
if (args.length >= 1) {
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true)) {
|
||||
return true;
|
||||
}
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
} else if (sender instanceof Player) {
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
if (jPlayer == null) {
|
||||
if (args.length >= 1)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfo"));
|
||||
else
|
||||
Jobs.getCommandManager().sendUsage(sender, "quests");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (jPlayer.getQuestProgressions().isEmpty()) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.error.noquests"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getUserName(), "[questsDone]", jPlayer.getDoneQuests()));
|
||||
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||
for (QuestProgression q : list) {
|
||||
String progressLine = Jobs.getCommandManager().jobProgressMessage(q.getQuest().getAmount(), q.getAmountDone());
|
||||
if (q.isComplited())
|
||||
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
|
||||
RawMessage rm = new RawMessage();
|
||||
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine",
|
||||
"[progress]", progressLine,
|
||||
"[questName]", q.getQuest().getQuestName(),
|
||||
"[done]", q.getAmountDone(),
|
||||
"[required]", q.getQuest().getAmount());
|
||||
|
||||
List<String> hoverMsgs = Jobs.getLanguage().getMessageList("command.quests.output.hover");
|
||||
List<String> hoverList = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < hoverMsgs.size(); i++) {
|
||||
String current = hoverMsgs.get(i);
|
||||
current = current.replace("[jobName]", jobProg.getJob().getName());
|
||||
current = current.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
||||
if (current.contains("[desc]")) {
|
||||
for (String one : q.getQuest().getDescription()) {
|
||||
hoverList.add(one);
|
||||
}
|
||||
} else
|
||||
hoverList.add(current);
|
||||
}
|
||||
|
||||
String hover = "";
|
||||
|
||||
for (String one : hoverList) {
|
||||
if (!hover.isEmpty())
|
||||
hover += "\n";
|
||||
hover += one;
|
||||
}
|
||||
|
||||
// hover += "&f" + jobProg.getJob().getName();
|
||||
// if (!q.getQuest().getDescription().isEmpty()) {
|
||||
//
|
||||
// for (String one : q.getQuest().getDescription()) {
|
||||
// hover += "\n&7";
|
||||
// hover += one;
|
||||
// }
|
||||
// }
|
||||
// hover += "\n&7New quest in: &8" + TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis());
|
||||
rm.add(msg, hover);
|
||||
rm.show(sender);
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobPermission;
|
||||
import com.gamingmesh.jobs.container.Quest;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
@ -120,6 +121,229 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyValues {
|
||||
private String type = null;
|
||||
private String subType = "";
|
||||
private String meta = "";
|
||||
private int id = 0;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSubType() {
|
||||
return subType;
|
||||
}
|
||||
|
||||
public void setSubType(String subType) {
|
||||
this.subType = subType;
|
||||
}
|
||||
|
||||
public String getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public KeyValues getKeyValue(String myKey, ActionType actionType, String jobName) {
|
||||
|
||||
String type = null;
|
||||
String subType = "";
|
||||
String meta = "";
|
||||
int id = 0;
|
||||
|
||||
if (myKey.contains("-")) {
|
||||
// uses subType
|
||||
subType = ":" + myKey.split("-")[1];
|
||||
meta = myKey.split("-")[1];
|
||||
myKey = myKey.split("-")[0];
|
||||
}
|
||||
|
||||
Material material = Material.matchMaterial(myKey);
|
||||
|
||||
if (material == null)
|
||||
material = Material.getMaterial(myKey.replace(" ", "_").toUpperCase());
|
||||
|
||||
if (material == null) {
|
||||
// try integer method
|
||||
Integer matId = null;
|
||||
try {
|
||||
matId = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
if (matId != null) {
|
||||
material = Material.getMaterial(matId);
|
||||
if (material != null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
||||
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (actionType == ActionType.EXPLORE)
|
||||
material = null;
|
||||
|
||||
c: if (material != null) {
|
||||
|
||||
// Need to include thos ones and count as regular blocks
|
||||
switch (myKey.replace("_", "").toLowerCase()) {
|
||||
case "itemframe":
|
||||
type = "ITEM_FRAME";
|
||||
id = 18;
|
||||
meta = "1";
|
||||
break c;
|
||||
case "painting":
|
||||
type = "PAINTING";
|
||||
id = 9;
|
||||
meta = "1";
|
||||
break c;
|
||||
case "armorstand":
|
||||
type = "ARMOR_STAND";
|
||||
id = 30;
|
||||
meta = "1";
|
||||
break c;
|
||||
}
|
||||
|
||||
// Break and Place actions MUST be blocks
|
||||
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) {
|
||||
if (!material.isBlock()) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey
|
||||
+ "! Material must be a block!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// START HACK
|
||||
/*
|
||||
* Historically, GLOWING_REDSTONE_ORE would ONLY work as REDSTONE_ORE, and putting
|
||||
* GLOWING_REDSTONE_ORE in the configuration would not work. Unfortunately, this is
|
||||
* completely backwards and wrong.
|
||||
*
|
||||
* To maintain backwards compatibility, all instances of REDSTONE_ORE should normalize
|
||||
* to GLOWING_REDSTONE_ORE, and warn the user to change their configuration. In the
|
||||
* future this hack may be removed and anybody using REDSTONE_ORE will have their
|
||||
* configurations broken.
|
||||
*/
|
||||
if (material == Material.REDSTONE_ORE && actionType == ActionType.BREAK) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||
material = Material.GLOWING_REDSTONE_ORE;
|
||||
}
|
||||
// END HACK
|
||||
|
||||
type = material.toString();
|
||||
id = material.getId();
|
||||
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
|
||||
|
||||
// check entities
|
||||
EntityType entity = EntityType.fromName(myKey);
|
||||
if (entity == null) {
|
||||
try {
|
||||
entity = EntityType.valueOf(myKey.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null && entity.isAlive()) {
|
||||
type = entity.toString();
|
||||
id = entity.getTypeId();
|
||||
|
||||
// using breeder finder
|
||||
if (actionType == ActionType.BREED)
|
||||
Jobs.getGCManager().setBreederFinder(true);
|
||||
}
|
||||
|
||||
switch (myKey.toLowerCase()) {
|
||||
case "skeletonwither":
|
||||
type = "SkeletonWither";
|
||||
id = 51;
|
||||
meta = "1";
|
||||
break;
|
||||
case "skeletonstray":
|
||||
type = "SkeletonStray";
|
||||
id = 51;
|
||||
meta = "2";
|
||||
break;
|
||||
case "zombievillager":
|
||||
type = "ZombieVillager";
|
||||
id = 54;
|
||||
meta = "1";
|
||||
break;
|
||||
case "zombiehusk":
|
||||
type = "ZombieHusk";
|
||||
id = 54;
|
||||
meta = "2";
|
||||
break;
|
||||
case "horseskeleton":
|
||||
type = "HorseSkeleton";
|
||||
id = 100;
|
||||
meta = "1";
|
||||
break;
|
||||
case "horsezombie":
|
||||
type = "HorseZombie";
|
||||
id = 100;
|
||||
meta = "2";
|
||||
break;
|
||||
case "guardianelder":
|
||||
type = "GuardianElder";
|
||||
id = 68;
|
||||
meta = "1";
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (actionType == ActionType.ENCHANT) {
|
||||
Enchantment enchant = Enchantment.getByName(myKey);
|
||||
if (enchant != null)
|
||||
id = enchant.getId();
|
||||
type = myKey;
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
||||
type = myKey;
|
||||
} else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
int amount = 10;
|
||||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount + 1);
|
||||
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) {
|
||||
type = myKey.substring(1, myKey.length());
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
KeyValues kv = new KeyValues();
|
||||
kv.setId(id);
|
||||
kv.setMeta(meta);
|
||||
kv.setSubType(subType);
|
||||
kv.setType(type);
|
||||
|
||||
return kv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to load the jobs configuration
|
||||
*
|
||||
@ -209,6 +433,17 @@ public class ConfigManager {
|
||||
|
||||
String description = org.bukkit.ChatColor.translateAlternateColorCodes('&', jobSection.getString("description", ""));
|
||||
|
||||
List<String> fDescription = new ArrayList<String>();
|
||||
if (jobSection.contains("FullDescription")) {
|
||||
if (jobSection.isString("FullDescription"))
|
||||
fDescription.add(jobSection.getString("FullDescription"));
|
||||
else if (jobSection.isList("FullDescription"))
|
||||
fDescription.addAll(jobSection.getStringList("FullDescription"));
|
||||
for (int i = 0; i < fDescription.size(); i++) {
|
||||
fDescription.set(i, org.bukkit.ChatColor.translateAlternateColorCodes('&', fDescription.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
ChatColor color = ChatColor.WHITE;
|
||||
if (jobSection.contains("ChatColour")) {
|
||||
color = ChatColor.matchColor(jobSection.getString("ChatColour", ""));
|
||||
@ -481,10 +716,64 @@ public class ConfigManager {
|
||||
Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar, rejoinCd);
|
||||
|
||||
job.setFullDescription(fDescription);
|
||||
job.setMoneyEquation(incomeEquation);
|
||||
job.setXpEquation(expEquation);
|
||||
job.setPointsEquation(pointsEquation);
|
||||
|
||||
if (jobSection.contains("Quests")) {
|
||||
|
||||
List<Quest> quests = new ArrayList<Quest>();
|
||||
ConfigurationSection qsection = jobSection.getConfigurationSection("Quests");
|
||||
|
||||
for (String one : qsection.getKeys(false)) {
|
||||
try {
|
||||
|
||||
ConfigurationSection sqsection = qsection.getConfigurationSection(one);
|
||||
|
||||
String name = sqsection.getString("Name");
|
||||
|
||||
ActionType actionType = ActionType.getByName(sqsection.getString("Action"));
|
||||
KeyValues kv = getKeyValue(sqsection.getString("Target"), actionType, jobName);
|
||||
if (kv == null)
|
||||
continue;
|
||||
int amount = sqsection.getInt("Amount");
|
||||
int chance = sqsection.getInt("Chance");
|
||||
|
||||
List<String> commands = sqsection.getStringList("RewardCommands");
|
||||
List<String> desc = sqsection.getStringList("RewardDesc");
|
||||
|
||||
Quest quest = new Quest(name, job, actionType);
|
||||
|
||||
if (sqsection.contains("fromLevel") && sqsection.isInt("fromLevel")) {
|
||||
quest.setMinLvl(sqsection.getInt("fromLevel"));
|
||||
}
|
||||
|
||||
if (sqsection.contains("toLevel") && sqsection.isInt("toLevel")) {
|
||||
quest.setMaxLvl(sqsection.getInt("toLevel"));
|
||||
}
|
||||
|
||||
quest.setConfigName(one);
|
||||
quest.setAmount(amount);
|
||||
quest.setChance(chance);
|
||||
quest.setTargetId(kv.getId());
|
||||
quest.setTargetMeta(kv.getMeta());
|
||||
quest.setTargetName(kv.getType() + kv.getSubType());
|
||||
quest.setRewardCmds(commands);
|
||||
quest.setDescription(desc);
|
||||
quests.add(quest);
|
||||
|
||||
} catch (Exception e) {
|
||||
Jobs.getPluginLogger().warning("Cant load " + one + " quest for " + jobName);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Jobs.getPluginLogger().warning("Loaded " + quests.size() + " quests for " + jobName);
|
||||
job.setQuests(quests);
|
||||
}
|
||||
job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1));
|
||||
|
||||
Integer softIncomeLimit = null;
|
||||
Integer softExpLimit = null;
|
||||
Integer softPointsLimit = null;
|
||||
|
@ -70,6 +70,9 @@ public class GeneralConfigManager {
|
||||
public boolean PaymentMethodsPoints;
|
||||
public boolean PaymentMethodsExp;
|
||||
public int getSelectionTooldID;
|
||||
|
||||
private int ResetTimeHour;
|
||||
private int ResetTimeMinute;
|
||||
|
||||
// Limits
|
||||
public HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<CurrencyType, CurrencyLimit>();
|
||||
@ -498,6 +501,11 @@ public class GeneralConfigManager {
|
||||
c.getW().addComment("broadcast.on-level-up.levels", "For what levels you want to broadcast message? Keep it at 0 if you want for all of them");
|
||||
BroadcastingLevelUpLevels = c.getIntList("broadcast.on-level-up.levels", Arrays.asList(0));
|
||||
|
||||
c.getW().addComment("DailyQuests.ResetTime", "Defines time in 24hour format when we want to give out new daily quests",
|
||||
"Any daily quests given before reset will be invalid and new ones will be given out");
|
||||
ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4);
|
||||
ResetTimeMinute = c.get("DailyQuests.ResetTime.Minute", 0);
|
||||
|
||||
c.getW().addComment("max-jobs", "Maximum number of jobs a player can join.", "Use 0 for no maximum", "Keep in mind that jobs.max.[amount] will bypass this setting");
|
||||
maxJobs = c.get("max-jobs", 3);
|
||||
|
||||
@ -845,7 +853,6 @@ public class GeneralConfigManager {
|
||||
"With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file");
|
||||
JobsGUISwitcheButtons = c.get("JobsGUI.SwitcheButtons", false);
|
||||
c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command");
|
||||
JobsGUIOpenOnJoin = c.get("JobsGUI.OpenOnJoin", true);
|
||||
|
||||
Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
|
||||
guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0));
|
||||
@ -855,9 +862,6 @@ public class GeneralConfigManager {
|
||||
c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost");
|
||||
useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false);
|
||||
|
||||
// writer.addComment("Gui.UseJobsBrowse", "Do you want to use jobs browse gui instead of chat text");
|
||||
// UseJobsBrowse = c.get("Gui.UseJobsBrowse", true);
|
||||
// Write back config
|
||||
try {
|
||||
c.getW().save(f);
|
||||
} catch (IOException e) {
|
||||
@ -865,37 +869,6 @@ public class GeneralConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
// public synchronized void startMysql() {
|
||||
// File f = new File(plugin.getDataFolder(), "generalConfig.yml");
|
||||
// YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
|
||||
// String legacyUrl = config.getString("mysql-url");
|
||||
// if (legacyUrl != null) {
|
||||
// String jdbcString = "jdbc:mysql://";
|
||||
// if (legacyUrl.toLowerCase().startsWith(jdbcString)) {
|
||||
// legacyUrl = legacyUrl.substring(jdbcString.length());
|
||||
// String[] parts = legacyUrl.split("/");
|
||||
// if (parts.length >= 2) {
|
||||
// config.set("mysql-hostname", parts[0]);
|
||||
// config.set("mysql-database", parts[1]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// String username = config.getString("mysql-username");
|
||||
// if (username == null) {
|
||||
// Jobs.getPluginLogger().severe("mysql-username property invalid or missing");
|
||||
// }
|
||||
// String password = config.getString("mysql-password");
|
||||
// String hostname = config.getString("mysql-hostname");
|
||||
// String database = config.getString("mysql-database");
|
||||
// String prefix = config.getString("mysql-table-prefix");
|
||||
// if (plugin.isEnabled())
|
||||
// Jobs.setDAO(JobsDAOMySQL.initialize(plugin, hostname, database, username, password, prefix));
|
||||
// }
|
||||
//
|
||||
// public synchronized void startSqlite() {
|
||||
// Jobs.setDAO(JobsDAOSQLite.initialize(plugin));
|
||||
// }
|
||||
|
||||
public int getSelectionTooldID() {
|
||||
return getSelectionTooldID;
|
||||
}
|
||||
@ -903,4 +876,20 @@ public class GeneralConfigManager {
|
||||
public boolean isShowNewVersion() {
|
||||
return ShowNewVersion;
|
||||
}
|
||||
|
||||
public int getResetTimeHour() {
|
||||
return ResetTimeHour;
|
||||
}
|
||||
|
||||
public void setResetTimeHour(int resetTimeHour) {
|
||||
ResetTimeHour = resetTimeHour;
|
||||
}
|
||||
|
||||
public int getResetTimeMinute() {
|
||||
return ResetTimeMinute;
|
||||
}
|
||||
|
||||
public void setResetTimeMinute(int resetTimeMinute) {
|
||||
ResetTimeMinute = resetTimeMinute;
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ public class LanguageManager {
|
||||
c.get("general.info.time.hours", "&e%hours% &6hours ");
|
||||
c.get("general.info.time.mins", "&e%mins% &6min ");
|
||||
c.get("general.info.time.secs", "&e%secs% &6sec ");
|
||||
c.get("general.info.invalidPage", "&cInvalid page");
|
||||
c.get("general.admin.error", "&cThere was an error in the command.");
|
||||
c.get("general.admin.success", "&eYour command has been performed.");
|
||||
c.get("general.error.noHelpPage", "&cThere is no help page by this number!");
|
||||
@ -213,10 +214,12 @@ public class LanguageManager {
|
||||
c.get("command.help.output.title", "&e-------&e ======= &6Jobs &e======= &e-------");
|
||||
c.get("command.help.output.page", "&e-----&e ====== Page &6[1] &eof &6[2] &e====== &e-----");
|
||||
c.get("command.help.output.fliperSimbols", "&e----------");
|
||||
c.get("command.help.output.prev", "&e--- <<<<< &6Prev page &e|");
|
||||
c.get("command.help.output.prevOff", "&7--- <<<<< Prev page &e|");
|
||||
c.get("command.help.output.next", "&e|&6 Next Page &e>>>> ---");
|
||||
c.get("command.help.output.nextOff", "&e|&7 Next Page >>>> ---");
|
||||
|
||||
c.get("command.help.output.prevPage", "&2----<< &6Prev ");
|
||||
c.get("command.help.output.prevPageOff", "&7----<< Prev ");
|
||||
c.get("command.help.output.nextPage", "&6 Next &2>>----");
|
||||
c.get("command.help.output.nextPageOff", "&7 Next >>----");
|
||||
c.get("command.help.output.pageCount", "&2[current]/[total]");
|
||||
|
||||
c.get("command.points.help.info", "Shows how much points player have.");
|
||||
c.get("command.points.help.args", "[playername]");
|
||||
@ -310,6 +313,7 @@ public class LanguageManager {
|
||||
Jobs.getGCManager().commandArgs.put("info", Arrays.asList("[jobname]", "[action]"));
|
||||
c.get("command.info.help.actions", "&eValid actions are: &f%actions%");
|
||||
c.get("command.info.help.max", " - &emax level:&f ");
|
||||
c.get("command.info.help.newMax", " &eMax level: &f[max]");
|
||||
c.get("command.info.help.material", "&7%material%");
|
||||
|
||||
c.get("command.info.help.levelRange", " &a(&e%levelFrom% &a- &e%levelUntil% &alevels)");
|
||||
@ -382,6 +386,8 @@ public class LanguageManager {
|
||||
c.get("command.join.error.rejoin", "&cCan't rejoin this job. Wait [time]");
|
||||
c.get("command.join.success", "You have joined the job %jobname%.");
|
||||
|
||||
c.get("command.join.confirm", "&2Click to confirm join action for &7[jobname] &2job.");
|
||||
|
||||
c.get("command.leave.help.info", "Leave the selected job.");
|
||||
c.get("command.leave.help.args", "[oldplayerjob]");
|
||||
Jobs.getGCManager().commandArgs.put("leave", Arrays.asList("[oldplayerjob]"));
|
||||
@ -402,6 +408,27 @@ public class LanguageManager {
|
||||
c.get("command.browse.output.totalWorkers", " &7Workers: &e[amount]");
|
||||
c.get("command.browse.output.penalty", " &4Penalty: &c[amount]%");
|
||||
c.get("command.browse.output.bonus", " &2Bonus: &a[amount]%");
|
||||
|
||||
|
||||
c.get("command.browse.output.newHeader", "&2========== [amount] Available Jobs =========");
|
||||
c.get("command.browse.output.list", " &8[place]. &7[jobname]");
|
||||
c.get("command.browse.output.click", "&bClick on the job to see more info about it!");
|
||||
c.get("command.browse.output.detailed", "&bClick to see more detailed list on job actions");
|
||||
|
||||
c.get("command.browse.output.jobHeader", "&2========== [jobname] =========");
|
||||
c.get("command.browse.output.chooseJob", "&7&n&oChoose this job");
|
||||
c.get("command.browse.output.chooseJobHover", "&7Click here to get this job");
|
||||
|
||||
|
||||
c.get("command.quests.help.info", "List available quests");
|
||||
c.get("command.quests.help.args", "(playername)");
|
||||
c.get("command.quests.error.noquests", "There are no jobs you can join.");
|
||||
c.get("command.quests.toplineseparator", "&7*********************** &6[playerName]&2(&f[questsDone]&2) &7***********************");
|
||||
c.get("command.quests.output.completed", "&2 !Completed!&r ");
|
||||
c.get("command.quests.output.questLine", "[progress] &7[questName] &f[done]&7/&8[required]");
|
||||
c.get("command.quests.output.hover", Arrays.asList("&f[jobName]", "[desc]", "&7New quest in: [time]"));
|
||||
|
||||
|
||||
|
||||
c.get("command.fire.help.info", "Fire the player from the job.");
|
||||
c.get("command.fire.help.args", "[playername] [jobname]");
|
||||
|
@ -23,6 +23,7 @@ import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -80,6 +81,11 @@ public class Job {
|
||||
|
||||
private Parser moneyEquation, xpEquation, pointsEquation;
|
||||
|
||||
private List<String> fDescription = new ArrayList<String>();
|
||||
|
||||
private List<Quest> quests = new ArrayList<Quest>();
|
||||
private int maxDailyQuests = 1;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param jobName - the name of the job
|
||||
@ -308,7 +314,7 @@ public class Job {
|
||||
JobsPlayer player = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
if (player != null)
|
||||
return player.getMaxJobLevelAllowed(this);
|
||||
}
|
||||
}
|
||||
return getMaxLevel() > getVipMaxLevel() ? getMaxLevel() : getVipMaxLevel();
|
||||
}
|
||||
|
||||
@ -409,4 +415,65 @@ public class Job {
|
||||
public void setRejoinCd(Long rejoinCd) {
|
||||
this.rejoinCd = rejoinCd;
|
||||
}
|
||||
|
||||
public List<String> getFullDescription() {
|
||||
return fDescription;
|
||||
}
|
||||
|
||||
public void setFullDescription(List<String> fDescription) {
|
||||
this.fDescription = fDescription;
|
||||
}
|
||||
|
||||
public List<Quest> getQuests() {
|
||||
return quests;
|
||||
}
|
||||
|
||||
public Quest getQuest(String name) {
|
||||
for (Quest one : quests) {
|
||||
if (one.getConfigName().equalsIgnoreCase(name))
|
||||
return one;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setQuests(List<Quest> quests) {
|
||||
this.quests.clear();
|
||||
this.quests = quests;
|
||||
}
|
||||
|
||||
// public Quest getNextQuest() {
|
||||
// return getNextQuest(null, null);
|
||||
// }
|
||||
|
||||
public Quest getNextQuest(List<String> excludeQuests, Integer level) {
|
||||
List<Quest> ls = new ArrayList<Quest>(this.quests);
|
||||
Collections.shuffle(ls);
|
||||
|
||||
int i = 0;
|
||||
while (true) {
|
||||
i++;
|
||||
Random rand = new Random(System.nanoTime());
|
||||
int target = rand.nextInt(100);
|
||||
for (Quest one : ls) {
|
||||
if (one.getChance() >= target)
|
||||
if (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase())) {
|
||||
|
||||
if (!one.isInLevelRange(level))
|
||||
continue;
|
||||
|
||||
return one;
|
||||
}
|
||||
}
|
||||
if (i > 20)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxDailyQuests() {
|
||||
return maxDailyQuests;
|
||||
}
|
||||
|
||||
public void setMaxDailyQuests(int maxDailyQuests) {
|
||||
this.maxDailyQuests = maxDailyQuests;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
public class JobInfo {
|
||||
private ActionType actionType;
|
||||
private int id;
|
||||
private String meta;
|
||||
private String meta;
|
||||
private String name;
|
||||
private double baseIncome, baseXp, basePoints;
|
||||
private Parser moneyEquation, xpEquation, pointsEquation;
|
||||
|
@ -23,7 +23,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -76,6 +75,9 @@ public class JobsPlayer {
|
||||
private HashMap<String, Boolean> permissionsCache = null;
|
||||
private Long lastPermissionUpdate = -1L;
|
||||
|
||||
private HashMap<String, List<QuestProgression>> qProgression = new HashMap<String, List<QuestProgression>>();
|
||||
private int doneQuests = 0;
|
||||
|
||||
public JobsPlayer(String userName, OfflinePlayer player) {
|
||||
this.userName = userName;
|
||||
this.OffPlayer = player;
|
||||
@ -583,6 +585,8 @@ public class JobsPlayer {
|
||||
* @return false - they are not in the job
|
||||
*/
|
||||
public boolean isInJob(Job job) {
|
||||
if (job == null)
|
||||
return false;
|
||||
for (JobProgression prog : progression) {
|
||||
if (prog.getJob().isSame(job))
|
||||
return true;
|
||||
@ -802,4 +806,126 @@ public class JobsPlayer {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean inDailyQuest(Job job, String questName) {
|
||||
|
||||
List<QuestProgression> qpl = this.qProgression.get(job.getName());
|
||||
if (qpl == null)
|
||||
return false;
|
||||
|
||||
for (QuestProgression one : qpl) {
|
||||
if (one.getQuest().getConfigName().equalsIgnoreCase(questName))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<String> getQuestNameList(Job job, ActionType type) {
|
||||
List<String> ls = new ArrayList<String>();
|
||||
if (!this.isInJob(job))
|
||||
return ls;
|
||||
|
||||
List<QuestProgression> qpl = this.qProgression.get(job.getName());
|
||||
|
||||
if (qpl == null)
|
||||
return ls;
|
||||
|
||||
for (QuestProgression one : qpl) {
|
||||
|
||||
if (!one.isEnded() && (type == null || type.name().equals(one.getQuest().getAction().name())))
|
||||
ls.add(one.getQuest().getConfigName().toLowerCase());
|
||||
}
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
public void resetQuests() {
|
||||
for (JobProgression one : this.getJobProgression()) {
|
||||
for (QuestProgression oneQ : this.getQuestProgressions(one.getJob())) {
|
||||
oneQ.setValidUntil(0L);
|
||||
}
|
||||
}
|
||||
getQuestProgressions();
|
||||
}
|
||||
|
||||
public List<QuestProgression> getQuestProgressions() {
|
||||
List<QuestProgression> g = new ArrayList<QuestProgression>();
|
||||
for (JobProgression one : this.getJobProgression()) {
|
||||
g.addAll(this.getQuestProgressions(one.getJob()));
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
public List<QuestProgression> getQuestProgressions(Job job) {
|
||||
return getQuestProgressions(job, null);
|
||||
}
|
||||
|
||||
public List<QuestProgression> getQuestProgressions(Job job, ActionType type) {
|
||||
if (!this.isInJob(job))
|
||||
return null;
|
||||
List<QuestProgression> g = new ArrayList<QuestProgression>();
|
||||
|
||||
if (this.qProgression.get(job.getName()) != null)
|
||||
g = new ArrayList<QuestProgression>(this.qProgression.get(job.getName()));
|
||||
|
||||
List<QuestProgression> tmp = new ArrayList<QuestProgression>();
|
||||
|
||||
if (!g.isEmpty()) {
|
||||
if (g.get(0).isEnded()) {
|
||||
g.clear();
|
||||
this.qProgression.clear();
|
||||
}
|
||||
}
|
||||
|
||||
for (QuestProgression one : new ArrayList<QuestProgression>(g)) {
|
||||
QuestProgression qp = one;
|
||||
if (qp == null || !qp.isValid()) {
|
||||
Quest q = job.getNextQuest(getQuestNameList(job, type), this.getJobProgression(job).getLevel());
|
||||
|
||||
if (q == null)
|
||||
continue;
|
||||
|
||||
qp = new QuestProgression(q);
|
||||
|
||||
if (g.size() >= job.getMaxDailyQuests())
|
||||
continue;
|
||||
|
||||
g.add(qp);
|
||||
}
|
||||
|
||||
if (type == null || type.name().equals(qp.getQuest().getAction().name()))
|
||||
tmp.add(qp);
|
||||
}
|
||||
|
||||
this.qProgression.put(job.getName(), g);
|
||||
|
||||
if (g.size() < job.getMaxDailyQuests()) {
|
||||
for (int i = g.size(); i < job.getMaxDailyQuests(); i++) {
|
||||
Quest q = job.getNextQuest(getQuestNameList(job, type), this.getJobProgression(job).getLevel());
|
||||
|
||||
if (q == null)
|
||||
continue;
|
||||
QuestProgression qp = new QuestProgression(q);
|
||||
g.add(qp);
|
||||
|
||||
if (type == null || type.name().equals(qp.getQuest().getAction().name()))
|
||||
tmp.add(qp);
|
||||
}
|
||||
}
|
||||
this.qProgression.put(job.getName(), g);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public int getDoneQuests() {
|
||||
return doneQuests;
|
||||
}
|
||||
|
||||
public void setDoneQuests(int doneQuests) {
|
||||
this.doneQuests = doneQuests;
|
||||
}
|
||||
|
||||
public void addDoneQuest() {
|
||||
this.doneQuests++;
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,12 @@ public class LocaleReader {
|
||||
return config.getStringList(path);
|
||||
}
|
||||
|
||||
public List<String> get(String path, List<String> list) {
|
||||
config.addDefault(path, list);
|
||||
copySetting(path);
|
||||
return config.getStringList(path);
|
||||
}
|
||||
|
||||
public String get(String path, String boo) {
|
||||
config.addDefault(path, boo);
|
||||
copySetting(path);
|
||||
|
@ -9,14 +9,16 @@ public class PlayerInfo {
|
||||
int id;
|
||||
String name = "Unknown";
|
||||
private Long seen;
|
||||
private Integer questsDone;
|
||||
private UUID uuid;
|
||||
private JobsPlayer player;
|
||||
|
||||
public PlayerInfo(String name, int id, UUID uuid, Long seen) {
|
||||
public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
this.seen = seen;
|
||||
this.questsDone = questsDone;
|
||||
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
|
||||
}
|
||||
|
||||
@ -45,4 +47,12 @@ public class PlayerInfo {
|
||||
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
|
||||
return player;
|
||||
}
|
||||
|
||||
public Integer getQuestsDone() {
|
||||
return questsDone;
|
||||
}
|
||||
|
||||
public void setQuestsDone(Integer questsDone) {
|
||||
this.questsDone = questsDone;
|
||||
}
|
||||
}
|
||||
|
180
src/main/java/com/gamingmesh/jobs/container/Quest.java
Normal file
180
src/main/java/com/gamingmesh/jobs/container/Quest.java
Normal file
@ -0,0 +1,180 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
public class Quest {
|
||||
|
||||
private String configName;
|
||||
private String questName;
|
||||
private Job job;
|
||||
private ActionType action = null;
|
||||
private Long validUntil = 0L;
|
||||
|
||||
private int id;
|
||||
private String meta;
|
||||
private String name;
|
||||
|
||||
private int chance = 0;
|
||||
private Integer minLvl = null;
|
||||
private Integer maxLvl = null;
|
||||
|
||||
private int amount = Integer.MAX_VALUE;
|
||||
|
||||
private List<String> rewardCmds = new ArrayList<String>();
|
||||
private List<String> rewards = new ArrayList<String>();
|
||||
|
||||
public Quest(String questName, Job job, ActionType action) {
|
||||
this.questName = questName;
|
||||
this.job = job;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public int getTargetId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setTargetId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTargetMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setTargetMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public String getTargetName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setTargetName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getRewardCmds() {
|
||||
return rewardCmds;
|
||||
}
|
||||
|
||||
public void setRewardCmds(List<String> rewardCmds) {
|
||||
this.rewardCmds = rewardCmds;
|
||||
}
|
||||
|
||||
public List<String> getDescription() {
|
||||
return rewards;
|
||||
}
|
||||
|
||||
public void setDescription(List<String> rewards) {
|
||||
this.rewards = rewards;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Long getValidUntil() {
|
||||
if (validUntil < System.currentTimeMillis()) {
|
||||
int hour = Jobs.getGCManager().getResetTimeHour();
|
||||
int minute = Jobs.getGCManager().getResetTimeMinute();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DAY_OF_MONTH, 1);
|
||||
c.set(Calendar.HOUR_OF_DAY, hour);
|
||||
c.set(Calendar.MINUTE, minute);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
if (c.getTimeInMillis() - System.currentTimeMillis() > 86400000) {
|
||||
c = Calendar.getInstance();
|
||||
c.set(Calendar.HOUR_OF_DAY, hour);
|
||||
c.set(Calendar.MINUTE, minute);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
}
|
||||
validUntil = c.getTimeInMillis();
|
||||
}
|
||||
|
||||
return validUntil;
|
||||
}
|
||||
|
||||
public void setValidUntil(Long validUntil) {
|
||||
this.validUntil = validUntil;
|
||||
}
|
||||
|
||||
public ActionType getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(ActionType action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Job getJob() {
|
||||
return Jobs.getJob(this.job.getName());
|
||||
}
|
||||
|
||||
public void setJob(Job job) {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
public int getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public void setChance(int chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public String getQuestName() {
|
||||
return questName;
|
||||
}
|
||||
|
||||
public void setQuestName(String questName) {
|
||||
this.questName = questName;
|
||||
}
|
||||
|
||||
public String getConfigName() {
|
||||
return configName;
|
||||
}
|
||||
|
||||
public void setConfigName(String configName) {
|
||||
this.configName = configName;
|
||||
}
|
||||
|
||||
public Integer getMinLvl() {
|
||||
return minLvl;
|
||||
}
|
||||
|
||||
public void setMinLvl(Integer minLvl) {
|
||||
this.minLvl = minLvl;
|
||||
}
|
||||
|
||||
public Integer getMaxLvl() {
|
||||
return maxLvl;
|
||||
}
|
||||
|
||||
public void setMaxLvl(Integer maxLvl) {
|
||||
this.maxLvl = maxLvl;
|
||||
}
|
||||
|
||||
public boolean isInLevelRange(Integer level) {
|
||||
if (level == null)
|
||||
return true;
|
||||
|
||||
if (this.getMinLvl() != null && level < this.getMinLvl())
|
||||
return false;
|
||||
|
||||
if (this.getMaxLvl() != null && level > this.getMaxLvl())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
public class QuestProgression {
|
||||
|
||||
private Quest quest;
|
||||
private int amountDone = 0;
|
||||
private Long validUntil;
|
||||
private boolean givenReward = false;
|
||||
|
||||
public QuestProgression(Quest quest) {
|
||||
this.quest = quest;
|
||||
validUntil = quest.getValidUntil();
|
||||
}
|
||||
|
||||
public Quest getQuest() {
|
||||
return quest.getJob().getQuest(quest.getConfigName());
|
||||
}
|
||||
|
||||
public void setQuest(Quest quest) {
|
||||
this.quest = quest;
|
||||
}
|
||||
|
||||
public int getAmountDone() {
|
||||
return amountDone;
|
||||
}
|
||||
|
||||
public void setAmountDone(int amountDone) {
|
||||
this.amountDone = amountDone;
|
||||
}
|
||||
|
||||
public Long getValidUntil() {
|
||||
return validUntil;
|
||||
}
|
||||
|
||||
public void setValidUntil(Long validUntil) {
|
||||
this.validUntil = validUntil;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return validUntil.equals(quest.getValidUntil());
|
||||
}
|
||||
|
||||
public boolean isEnded() {
|
||||
return validUntil < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isComplited() {
|
||||
return amountDone >= quest.getAmount();
|
||||
}
|
||||
|
||||
public void processQuest(JobsPlayer jPlayer, ActionInfo action) {
|
||||
|
||||
if (!quest.getAction().name().equals(action.getType().name()))
|
||||
return;
|
||||
|
||||
if (!quest.getTargetName().equalsIgnoreCase(action.getName()) && !quest.getTargetName().equalsIgnoreCase(action.getNameWithSub()))
|
||||
return;
|
||||
|
||||
if (!isComplited())
|
||||
amountDone++;
|
||||
|
||||
if (!isComplited())
|
||||
return;
|
||||
|
||||
if (!jPlayer.isOnline())
|
||||
return;
|
||||
|
||||
if (givenReward)
|
||||
return;
|
||||
|
||||
givenReward = true;
|
||||
|
||||
jPlayer.addDoneQuest();
|
||||
|
||||
List<String> cmds = quest.getRewardCmds();
|
||||
for (String one : cmds) {
|
||||
ServerCommandEvent ev = new ServerCommandEvent(Bukkit.getConsoleSender(), one.replace("[playerName]", jPlayer.getUserName()));
|
||||
Bukkit.getPluginManager().callEvent(ev);
|
||||
if (!ev.isCancelled()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ev.getCommand().startsWith("/") ? ev.getCommand().substring(1) : ev.getCommand());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@ import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -36,7 +36,6 @@ import com.gamingmesh.jobs.container.PlayerPoints;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
public abstract class JobsDAO {
|
||||
@ -55,7 +54,9 @@ public abstract class JobsDAO {
|
||||
public enum UserTableFields implements JobsTableInterface {
|
||||
player_uuid("varchar(36)", TablesFieldsType.varchar),
|
||||
username("text", TablesFieldsType.text),
|
||||
seen("bigint", TablesFieldsType.longNumber);
|
||||
seen("bigint", TablesFieldsType.longNumber),
|
||||
donequests("int", TablesFieldsType.number),
|
||||
quests("text", TablesFieldsType.text);
|
||||
|
||||
private String type;
|
||||
private TablesFieldsType fieldType;
|
||||
@ -787,10 +788,11 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prestt = null;
|
||||
ResultSet res2 = null;
|
||||
try {
|
||||
prestt = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`, `seen`) VALUES (?, ?, ?);", Statement.RETURN_GENERATED_KEYS);
|
||||
prestt = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`, `seen`, `donequests`) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS);
|
||||
prestt.setString(1, uuid.toString());
|
||||
prestt.setString(2, playerName);
|
||||
prestt.setLong(3, System.currentTimeMillis());
|
||||
prestt.setInt(4, 0);
|
||||
prestt.executeUpdate();
|
||||
|
||||
res2 = prestt.getGeneratedKeys();
|
||||
@ -798,9 +800,7 @@ public abstract class JobsDAO {
|
||||
if (res2.next())
|
||||
id = res2.getInt(1);
|
||||
|
||||
Debug.D("got id " + id);
|
||||
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, id, uuid, System.currentTimeMillis()));
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, id, uuid, System.currentTimeMillis(), 0));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -1266,7 +1266,11 @@ public abstract class JobsDAO {
|
||||
prest.setString(1, uuid.toString());
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
pInfo = new PlayerInfo(res.getString("username"), res.getInt("id"), uuid, res.getLong("seen"));
|
||||
pInfo = new PlayerInfo(
|
||||
res.getString("username"),
|
||||
res.getInt("id"), uuid,
|
||||
res.getLong("seen"),
|
||||
res.getInt("donequests"));
|
||||
Jobs.getPlayerManager().addPlayerToMap(pInfo);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@ -1292,7 +1296,12 @@ public abstract class JobsDAO {
|
||||
long seen = System.currentTimeMillis();
|
||||
try {
|
||||
seen = res.getLong("seen");
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(res.getString("username"), res.getInt("id"), UUID.fromString(res.getString("player_uuid")), seen));
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(
|
||||
res.getString("username"),
|
||||
res.getInt("id"),
|
||||
UUID.fromString(res.getString("player_uuid")),
|
||||
seen,
|
||||
res.getInt("donequests")));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
@ -1348,8 +1357,12 @@ public abstract class JobsDAO {
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
try {
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(res.getString("username"), res.getInt("id"), UUID.fromString(res.getString("player_uuid")), res.getLong(
|
||||
"seen")));
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(
|
||||
res.getString("username"),
|
||||
res.getInt("id"),
|
||||
UUID.fromString(res.getString("player_uuid")),
|
||||
res.getLong("seen"),
|
||||
res.getInt("donequests")));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
@ -1420,12 +1433,14 @@ public abstract class JobsDAO {
|
||||
return;
|
||||
PreparedStatement prest = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("UPDATE `" + prefix + "users` SET `seen` = ?, `username` = ? WHERE `id` = ?;");
|
||||
prest = conn.prepareStatement("UPDATE `" + prefix + "users` SET `seen` = ?, `username` = ?, `donequests` = ? WHERE `id` = ?;");
|
||||
prest.setLong(1, System.currentTimeMillis());
|
||||
prest.setString(2, player.getUserName());
|
||||
prest.setInt(3, player.getUserId());
|
||||
prest.setInt(3, player.getDoneQuests());
|
||||
prest.setInt(4, player.getUserId());
|
||||
prest.execute();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(prest);
|
||||
}
|
||||
@ -1437,10 +1452,11 @@ public abstract class JobsDAO {
|
||||
return;
|
||||
PreparedStatement prestt = null;
|
||||
try {
|
||||
prestt = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`, `seen`) VALUES (?, ?, ?);");
|
||||
prestt = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`, `seen`, `donequests`) VALUES (?, ?, ?, ?);");
|
||||
prestt.setString(1, player.getPlayerUUID().toString());
|
||||
prestt.setString(2, player.getUserName());
|
||||
prestt.setLong(3, player.getSeen());
|
||||
prestt.setInt(4, 0);
|
||||
prestt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@ -1456,7 +1472,12 @@ public abstract class JobsDAO {
|
||||
res.next();
|
||||
int id = res.getInt("id");
|
||||
player.setUserId(id);
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(player.getUserName(), id, player.getPlayerUUID(), player.getSeen()));
|
||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(
|
||||
player.getUserName(),
|
||||
id,
|
||||
player.getPlayerUUID(),
|
||||
player.getSeen(),
|
||||
res.getInt("donequests")));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
@ -18,10 +18,17 @@
|
||||
|
||||
package com.gamingmesh.jobs.i18n;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
|
||||
@ -77,6 +84,57 @@ public class Language {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
* @return the message
|
||||
*/
|
||||
public List<String> getMessageList(String key, Object... variables) {
|
||||
String missing = "MLF " + key + " ";
|
||||
|
||||
List<String> ls;
|
||||
if (customlocale.isList(key))
|
||||
ls = ColorsArray(customlocale.getStringList(key), true);
|
||||
else
|
||||
ls = !enlocale.getStringList(key).isEmpty() ? ColorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
|
||||
|
||||
if (variables != null && variables.length > 0)
|
||||
for (int i = 0; i < ls.size(); i++) {
|
||||
String msg = ls.get(i);
|
||||
for (int y = 0; y < variables.length; y += 2) {
|
||||
msg = msg.replace(String.valueOf(variables[y]), String.valueOf(variables[y + 1]));
|
||||
}
|
||||
msg = filterNewLine(msg);
|
||||
ls.set(i, ChatColor.translateAlternateColorCodes('&', msg));
|
||||
}
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
public String filterNewLine(String msg) {
|
||||
Pattern patern = Pattern.compile("([ ]?[\\/][n][$|\\s])");
|
||||
Matcher match = patern.matcher(msg);
|
||||
while (match.find()) {
|
||||
msg = msg.replace(match.group(0), "\n");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
public List<String> ColorsArray(List<String> text, Boolean colorize) {
|
||||
List<String> temp = new ArrayList<String>();
|
||||
for (String part : text) {
|
||||
if (colorize)
|
||||
part = Colors(part);
|
||||
temp.add(Colors(part));
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
public String Colors(String text) {
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
|
@ -46,6 +46,10 @@ public class PageInfo {
|
||||
return currentEntry - 1 >= start && currentEntry - 1 <= end;
|
||||
}
|
||||
|
||||
public boolean isBreak() {
|
||||
return currentEntry - 1 > end;
|
||||
}
|
||||
|
||||
public boolean isPageOk() {
|
||||
return isPageOk(this.currentPage);
|
||||
}
|
||||
@ -77,4 +81,7 @@ public class PageInfo {
|
||||
public int getTotalEntries() {
|
||||
return totalEntries;
|
||||
}
|
||||
}
|
||||
public int getPerPageCount(){
|
||||
return this.perPage;
|
||||
}
|
||||
}
|
@ -19,10 +19,20 @@ public class TimeManage {
|
||||
}
|
||||
|
||||
public static String to24hourShort(Long ticks) {
|
||||
long days = toDays(ticks);
|
||||
long hours = toHours(ticks);
|
||||
long minutes = toMin(ticks);
|
||||
long sec = toSec(ticks);
|
||||
long years = ticks / 1000 / 60 / 60 / 24 / 365;
|
||||
ticks = ticks - (years * 1000 * 60 * 60 * 24 * 365);
|
||||
|
||||
long days = ticks / 1000 / 60 / 60 / 24;
|
||||
ticks = ticks - (days * 1000 * 60 * 60 * 24);
|
||||
|
||||
long hours = ticks / 1000 / 60 / 60;
|
||||
ticks = ticks - (hours * 1000 * 60 * 60);
|
||||
|
||||
long minutes = ticks / 1000 / 60;
|
||||
ticks = ticks - (minutes * 1000 * 60);
|
||||
|
||||
long sec = ticks / 1000;
|
||||
ticks = ticks - (sec * 1000);
|
||||
|
||||
String time = "";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user