1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +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("");
Lore.add(Language.getDefaultMessage("command.info.gui.leftClick")); Lore.add(Language.getMessage("command.info.gui.leftClick"));
Lore.add(Language.getDefaultMessage("command.info.gui.rightClick")); Lore.add(Language.getMessage("command.info.gui.rightClick"));
ItemStack GuiItem = job.getGuiItem(); ItemStack GuiItem = job.getGuiItem();

View File

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

View File

@ -520,7 +520,22 @@ public class JobConfig {
double income = section.getDouble("income", 0.0); double income = section.getDouble("income", 0.0);
double experience = section.getDouble("experience", 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); job.setJobInfo(actionType, jobInfo);

View File

@ -470,7 +470,7 @@ public class JobsConfiguration {
modifyChatPrefix = getString("modify-chat-prefix", "&c[", config, writer, true); modifyChatPrefix = getString("modify-chat-prefix", "&c[", config, writer, true);
modifyChatSuffix = getString("modify-chat-suffix", "&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", 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"); "With this set to true names like Stone:1 will be translated to Granite", "Name list is in ItemList.yml file");
@ -1360,6 +1360,10 @@ public class JobsConfiguration {
GetConfigString("command.info.help.max", " - &emax level:&f ", 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.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.pickjob", "&ePick your job!", writer, conf, true);
GetConfigString("command.info.gui.jobinfo", "&e[jobname] info!", writer, conf, true); GetConfigString("command.info.gui.jobinfo", "&e[jobname] info!", writer, conf, true);
GetConfigString("command.info.gui.actions", "&eValid actions are:", writer, conf, true); GetConfigString("command.info.gui.actions", "&eValid actions are:", writer, conf, true);
@ -1390,6 +1394,8 @@ public class JobsConfiguration {
GetConfigString("command.info.output.brew.none", "%jobname% does not get money from brewing.", 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.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.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.enchant.none", "%jobname% does not get money from enchanting.", writer, conf, true);
GetConfigString("command.info.output.repair.info", "Repair", 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()); List<JobInfo> jobInfo = getJobInfo(action.getType());
for (JobInfo info : jobInfo) { 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.getIncome(level, numjobs); return info.getIncome(level, numjobs);
} }
} }
@ -237,9 +239,12 @@ public class Job {
public Double getExperience(ActionInfo action, int level, int numjobs) { public Double getExperience(ActionInfo action, int level, int numjobs) {
List<JobInfo> jobInfo = getJobInfo(action.getType()); List<JobInfo> jobInfo = getJobInfo(action.getType());
for (JobInfo info : jobInfo) { 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 info.getExperience(level, numjobs);
} }
}
return null; return null;
} }

View File

@ -27,8 +27,11 @@ public class JobInfo {
private String name; private String name;
private double baseIncome, baseXp; private double baseIncome, baseXp;
private Parser moneyEquation, xpEquation; 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) { 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.actionType = actionType;
this.id = id; this.id = id;
this.meta = meta; this.meta = meta;
@ -37,6 +40,20 @@ public class JobInfo {
this.moneyEquation = moneyEquation; this.moneyEquation = moneyEquation;
this.baseXp = baseXp; this.baseXp = baseXp;
this.xpEquation = xpEquation; this.xpEquation = xpEquation;
this.fromLevel = fromLevel;
this.untilLevel = untilLevel;
}
public int getFromLevel() {
return this.fromLevel;
}
public int getUntilLevel() {
return this.untilLevel;
}
public boolean isInLevelRange(int level) {
return level >= fromLevel && (level <= untilLevel || untilLevel == -1);
} }
public String getName() { public String getName() {

View File

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

View File

@ -554,7 +554,7 @@ public class JobsListener implements Listener {
if (meinOk != null) { if (meinOk != null) {
event.setCancelled(true); 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 name: Jobs
description: Jobs Plugin for the BukkitAPI description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin main: com.gamingmesh.jobs.JobsPlugin
version: 2.60.0 version: 2.61.0
author: phrstbrn author: phrstbrn
softdepend: [Vault, CoreProtect, MythicMobs, McMMO] softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
commands: commands: