1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-29 04:18:07 +01:00

Action limiting by jobs lvl

This commit is contained in:
Zrips 2016-01-22 14:42:25 +02:00
parent 7b049fe670
commit e172048f1f
9 changed files with 144 additions and 75 deletions

View File

@ -123,8 +123,8 @@ public class GuiTools {
}
Lore.add("");
Lore.add(Language.getDefaultMessage("command.info.gui.leftClick"));
Lore.add(Language.getDefaultMessage("command.info.gui.rightClick"));
Lore.add(Language.getMessage("command.info.gui.leftClick"));
Lore.add(Language.getMessage("command.info.gui.rightClick"));
ItemStack GuiItem = job.getGuiItem();

View File

@ -183,19 +183,19 @@ public class JobsCommands implements CommandExecutor {
return true;
}
@JobCommand
public boolean fixuuid(CommandSender sender, String[] args) throws IOException {
if (args.length > 0) {
sendUsage(sender, "fixuuid");
return true;
}
sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting uuid fix proccess, this can take up to minute depending on your data base size.");
Jobs.getJobsDAO().fixUuid(sender);
return true;
}
// @JobCommand
// public boolean fixuuid(CommandSender sender, String[] args) throws IOException {
//
// if (args.length > 0) {
// sendUsage(sender, "fixuuid");
// return true;
// }
//
// sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting uuid fix proccess, this can take up to minute depending on your data base size.");
// Jobs.getJobsDAO().fixUuid(sender);
//
// return true;
// }
@JobCommand
public boolean convert(CommandSender sender, String[] args) throws IOException {
@ -316,6 +316,18 @@ public class JobsCommands implements CommandExecutor {
return true;
}
@JobCommand
public boolean test(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
Jobs.getJobsDAO().saveLog(jPlayer);
return true;
}
@JobCommand
public boolean leave(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
@ -1676,7 +1688,10 @@ public class JobsCommands implements CommandExecutor {
message.append(" ");
message.append(Language.getMessage("command.info.help.material").replace("%material%", materialName));
message.append(" -> ");
if (!info.isInLevelRange(prog.getLevel()))
message.append(org.bukkit.ChatColor.RED + " -> ");
else
message.append(" -> ");
message.append(xpColor.toString());
message.append(xpString);
@ -1685,6 +1700,16 @@ public class JobsCommands implements CommandExecutor {
message.append(incomeColor.toString());
message.append(Jobs.getEconomy().format(income));
if (info.getFromLevel() > 1 && info.getUntilLevel() != -1)
message.append(Language.getMessage("command.info.help.levelRange").replace("%levelFrom%", "" + info.getFromLevel()).replace("%levelUntil%", "" + info
.getUntilLevel()));
if (info.getFromLevel() > 1 && info.getUntilLevel() == -1)
message.append(Language.getMessage("command.info.help.levelFrom").replace("%levelFrom%", "" + info.getFromLevel()));
if (info.getFromLevel() == 1 && info.getUntilLevel() != -1)
message.append(Language.getMessage("command.info.help.levelUntil").replace("%levelUntil%", "" + info.getUntilLevel()));
message.append('\n');
}
return message.toString();

View File

@ -520,7 +520,22 @@ public class JobConfig {
double income = section.getDouble("income", 0.0);
double experience = section.getDouble("experience", 0.0);
jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation));
int fromlevel = 1;
if (section.isInt("from-level"))
fromlevel = section.getInt("from-level");
int untilLevel = -1;
if (section.isInt("until-level")) {
untilLevel = section.getInt("until-level");
if (untilLevel < fromlevel) {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid until-level in " + actionType.getName() + " for type property: " + key
+ "! It will be not set.");
untilLevel = -1;
}
}
jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, fromlevel, untilLevel));
}
}
job.setJobInfo(actionType, jobInfo);

View File

@ -470,7 +470,7 @@ public class JobsConfiguration {
modifyChatPrefix = getString("modify-chat-prefix", "&c[", config, writer, true);
modifyChatSuffix = getString("modify-chat-suffix", "&c]", config, writer, true);
modifyChatSeparator = getString("modify-chat-seperator", " ", config, writer, true);
modifyChatSeparator = getString("modify-chat-separator", " ", config, writer, true);
writer.addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names",
"With this set to true names like Stone:1 will be translated to Granite", "Name list is in ItemList.yml file");
@ -1359,6 +1359,10 @@ public class JobsConfiguration {
GetConfigString("command.info.help.actions", "&eValid actions are: &f%actions%", writer, conf, true);
GetConfigString("command.info.help.max", " - &emax level:&f ", writer, conf, true);
GetConfigString("command.info.help.material", "&7%material%", writer, conf, true);
GetConfigString("command.info.help.levelRange", " &a(&e%levelFrom% &a- &e%levelUntil% &alevels)", writer, conf, true);
GetConfigString("command.info.help.levelFrom", " &a(from &e%levelFrom% &alevel)", writer, conf, true);
GetConfigString("command.info.help.levelUntil", " &a(until &e%levelUntil% &alevel)", writer, conf, true);
GetConfigString("command.info.gui.pickjob", "&ePick your job!", writer, conf, true);
GetConfigString("command.info.gui.jobinfo", "&e[jobname] info!", writer, conf, true);
@ -1389,7 +1393,9 @@ public class JobsConfiguration {
GetConfigString("command.info.output.brew.info", "Brew", writer, conf, true);
GetConfigString("command.info.output.brew.none", "%jobname% does not get money from brewing.", writer, conf, true);
GetConfigString("command.info.output.eat.info", "Eat", writer, conf, true);
GetConfigString("command.info.output.eat.none", "%jobname% does not get money from eating food.", writer, conf, true);
GetConfigString("command.info.output.eat.none", "%jobname% does not get money from eating food.", writer, conf, true);
GetConfigString("command.info.output.dye.info", "Dye", writer, conf, true);
GetConfigString("command.info.output.dye.none", "%jobname% does not get money from dyeing.", writer, conf, true);
GetConfigString("command.info.output.enchant.info", "Enchant", writer, conf, true);
GetConfigString("command.info.output.enchant.none", "%jobname% does not get money from enchanting.", writer, conf, true);
GetConfigString("command.info.output.repair.info", "Repair", writer, conf, true);

View File

@ -220,6 +220,8 @@ public class Job {
List<JobInfo> jobInfo = getJobInfo(action.getType());
for (JobInfo info : jobInfo) {
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())) {
if (!info.isInLevelRange(level))
return 0D;
return info.getIncome(level, numjobs);
}
}
@ -237,8 +239,11 @@ public class Job {
public Double getExperience(ActionInfo action, int level, int numjobs) {
List<JobInfo> jobInfo = getJobInfo(action.getType());
for (JobInfo info : jobInfo) {
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub()))
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())){
if (!info.isInLevelRange(level))
return 0D;
return info.getExperience(level, numjobs);
}
}
return null;
}

View File

@ -21,59 +21,76 @@ package com.gamingmesh.jobs.container;
import com.gamingmesh.jobs.resources.jfep.Parser;
public class JobInfo {
private ActionType actionType;
private int id;
private String meta;
private String name;
private double baseIncome, baseXp;
private Parser moneyEquation, xpEquation;
private ActionType actionType;
private int id;
private String meta;
private String name;
private double baseIncome, baseXp;
private Parser moneyEquation, xpEquation;
private int fromLevel;
private int untilLevel;
public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation) {
this.actionType = actionType;
this.id = id;
this.meta = meta;
this.name = name;
this.baseIncome = baseIncome;
this.moneyEquation = moneyEquation;
this.baseXp = baseXp;
this.xpEquation = xpEquation;
}
public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation, int fromLevel,
int untilLevel) {
this.actionType = actionType;
this.id = id;
this.meta = meta;
this.name = name;
this.baseIncome = baseIncome;
this.moneyEquation = moneyEquation;
this.baseXp = baseXp;
this.xpEquation = xpEquation;
this.fromLevel = fromLevel;
this.untilLevel = untilLevel;
}
public String getName() {
return this.name;
}
public int getFromLevel() {
return this.fromLevel;
}
public int getId() {
return this.id;
}
public int getUntilLevel() {
return this.untilLevel;
}
public ActionType getActionType() {
return this.actionType;
}
public boolean isInLevelRange(int level) {
return level >= fromLevel && (level <= untilLevel || untilLevel == -1);
}
public String getMeta() {
return this.meta;
}
public String getName() {
return this.name;
}
public double getBaseIncome() {
return this.baseIncome;
}
public int getId() {
return this.id;
}
public double getBaseXp() {
return this.baseXp;
}
public ActionType getActionType() {
return this.actionType;
}
public double getIncome(int level, int numjobs) {
moneyEquation.setVariable("joblevel", level);
moneyEquation.setVariable("numjobs", numjobs);
moneyEquation.setVariable("baseincome", baseIncome);
return moneyEquation.getValue();
}
public String getMeta() {
return this.meta;
}
public double getExperience(int level, int numjobs) {
xpEquation.setVariable("joblevel", level);
xpEquation.setVariable("numjobs", numjobs);
xpEquation.setVariable("baseexperience", baseXp);
return xpEquation.getValue();
}
public double getBaseIncome() {
return this.baseIncome;
}
public double getBaseXp() {
return this.baseXp;
}
public double getIncome(int level, int numjobs) {
moneyEquation.setVariable("joblevel", level);
moneyEquation.setVariable("numjobs", numjobs);
moneyEquation.setVariable("baseincome", baseIncome);
return moneyEquation.getValue();
}
public double getExperience(int level, int numjobs) {
xpEquation.setVariable("joblevel", level);
xpEquation.setVariable("numjobs", numjobs);
xpEquation.setVariable("baseexperience", baseXp);
return xpEquation.getValue();
}
}

View File

@ -643,12 +643,13 @@ public abstract class JobsDAO {
if (conn == null)
return;
try {
PreparedStatement prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `level` = ?, `experience` = ? WHERE `player_uuid` = ? AND `job` = ?;");
PreparedStatement prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `level` = ?, `experience` = ?, `username` = ? WHERE `player_uuid` = ? AND `job` = ?;");
for (JobProgression progression : player.getJobProgression()) {
prest.setInt(1, progression.getLevel());
prest.setInt(2, (int) progression.getExperience());
prest.setString(3, player.getPlayerUUID().toString());
prest.setString(4, progression.getJob().getName());
prest.setString(3, player.getPlayer().getName());
prest.setString(4, player.getPlayerUUID().toString());
prest.setString(5, progression.getJob().getName());
prest.execute();
}
prest.close();
@ -661,7 +662,7 @@ public abstract class JobsDAO {
* Save player-job information
* @param jobInfo - the information getting saved
*/
public synchronized void saveLog(JobsPlayer player) {
public void saveLog(JobsPlayer player) {
JobsConnection conn = getConnection();
if (conn == null)
return;
@ -743,7 +744,7 @@ public abstract class JobsDAO {
* Save player-explore information
* @param jobexplore - the information getting saved
*/
public synchronized void saveExplore() {
public void saveExplore() {
if (!Jobs.getExplore().isExploreEnabled())
return;
@ -783,7 +784,7 @@ public abstract class JobsDAO {
* Save player-explore information
* @param jobexplore - the information getting saved
*/
public synchronized void loadExplore() {
public void loadExplore() {
if (!Jobs.getExplore().isExploreEnabled())
return;
@ -839,7 +840,7 @@ public abstract class JobsDAO {
* @param toplist - toplist by jobs name
* @return
*/
public synchronized ArrayList<TopList> toplist(String jobsname, int limit) {
public ArrayList<TopList> toplist(String jobsname, int limit) {
ArrayList<TopList> jobs = new ArrayList<TopList>();
JobsConnection conn = getConnection();
if (conn == null)

View File

@ -554,7 +554,7 @@ public class JobsListener implements Listener {
if (meinOk != null) {
event.setCancelled(true);
ActionBar.send(player, Language.getDefaultMessage("limitedItem.error.levelup").replace("[jobname]", meinOk));
ActionBar.send(player, Language.getMessage("limitedItem.error.levelup").replace("[jobname]", meinOk));
}
}

View File

@ -1,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin
version: 2.60.0
version: 2.61.0
author: phrstbrn
softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
commands: