1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Jobs editor command

Still need to be optimized/fixed/expanded, this is only basic concept.
This commit is contained in:
Zrips 2017-08-13 16:31:41 +03:00
parent d1c24bed10
commit 25e3b87de5
7 changed files with 776 additions and 11 deletions

View File

@ -0,0 +1,617 @@
package com.gamingmesh.jobs.commands.list;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.RawMessage;
import com.gamingmesh.jobs.stuff.Util;
public class editjobs implements Cmd {
// [jobName] [add/del/edit]
@Override
@JobCommand(475)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (args.length == 0)
args = new String[] { "list" };
switch (args[0]) {
case "list":
if (args.length == 1) {
showPath(player, null, null, null);
for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage();
rm.add(" -> [" + one.getChatColor() + one.getName() + "&r]", one.getName(), "jobs editjobs list " + one.getName());
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
showPath(player, job, null, null);
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
RawMessage rm = new RawMessage();
rm.add(" -> &e[&6" + oneI.getName() + "&e]", oneI.getName(), "jobs editjobs list " + job.getName() + " " + oneI.getName());
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 3) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
showPath(player, job, actionT, null);
for (JobInfo one : action) {
String materialName = one.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().Translate(materialName, one);
materialName = org.bukkit.ChatColor.translateAlternateColorCodes('&', materialName);
RawMessage rm = new RawMessage();
rm.add(" -> &e[&6" + materialName + "&e] ", one.getName(), "jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + one.getName());
rm.add("&c[X]", "Remove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one.getName());
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(" -> &e[&2+&e]", "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName());
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
showPath(player, job, actionT, jInfo);
RawMessage rm = new RawMessage();
rm.add(" -> &eMoney: &6" + jInfo.getBaseIncome(), jInfo.getBaseIncome() + "", "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " money ");
rm.show(sender);
rm = new RawMessage();
rm.add(" -> &ePoints: &6" + jInfo.getBasePoints(), jInfo.getBasePoints() + "", "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName()
+ " points ");
rm.show(sender);
rm = new RawMessage();
rm.add(" -> &eExp: &6" + jInfo.getBaseXp(), jInfo.getBaseXp() + "", "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " exp ");
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "modify":
if (args.length == 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " " + type.getName() + " ");
sender.sendMessage(ChatColor.GOLD + "Enter new value");
return true;
}
if (args.length == 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Double value = null;
try {
value = Double.parseDouble(args[5]);
} catch (Exception e) {
return false;
}
sender.sendMessage("Set new value " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " " + type.getName() + " " + value);
String sType = null;
switch (type) {
case EXP:
sType = "experience";
jInfo.setBaseXp(value);
break;
case MONEY:
sType = "income";
jInfo.setBaseIncome(value);
break;
case POINTS:
sType = "points";
jInfo.setBasePoints(value);
break;
default:
break;
}
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath() + "/" + sType, value);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "remove":
// remove miner break stone:1
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo info : action) {
if (!info.getName().equalsIgnoreCase(args[3]))
continue;
jInfo = info;
break;
}
if (jInfo == null) {
player.sendMessage("Cant find this one");
return true;
}
action.remove(jInfo);
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath(), null);
sender.sendMessage("Removed");
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
// add miner break stone:1
if (args.length == 3) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
RawMessage rm = new RawMessage();
rm.add("&eEnter new name or press");
rm.add(" &6HAND ", "Press to grab info from item in your hand", "jobs editjobs add " + job.getName() + " " + actionT.getName() + " hand");
rm.add("&eor");
rm.add(" &6LOOKING AT", "Press to grab info from block you are looking", "jobs editjobs add " + job.getName() + " " + actionT.getName() + " looking");
rm.show(sender);
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " ");
return true;
}
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
String key = args[3];
switch (args[3]) {
case "hand":
ItemStack item = Jobs.getNms().getItemInMainHand(player);
key = item.getType().name() + "-" + item.getData().getData();
break;
case "looking":
case "lookingat":
Block block = Jobs.getNms().getTargetBlock(player, 30);
key = block.getType().name() + "-" + block.getData();
break;
}
String myKey = key;
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) {
player.sendMessage("Job " + job.getName() + " " + actionT.getName() + " is using ID: " + key + "!");
player.sendMessage("Please use the Material name instead: " + material.toString() + "!");
}
}
}
if (actionT == ActionType.EXPLORE)
material = null;
c: if (material != null) {
// Need to include thos ones and count as regular blocks
switch (key.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;
}
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE) {
if (!material.isBlock()) {
player.sendMessage("Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + key
+ "! Material must be a block!");
break;
}
}
if (material == Material.REDSTONE_ORE && actionT == ActionType.BREAK) {
player.sendMessage("Job " + job.getName() + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
player.sendMessage("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
player.sendMessage("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
player.sendMessage("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
material = Material.GLOWING_REDSTONE_ORE;
}
type = material.toString();
id = material.getId();
} else if (actionT == ActionType.KILL || actionT == ActionType.TAME || actionT == ActionType.BREED || actionT == ActionType.MILK) {
// check entities
EntityType entity = EntityType.fromName(key);
if (entity == null) {
try {
entity = EntityType.valueOf(key.toUpperCase());
} catch (IllegalArgumentException e) {
}
}
if (entity != null && entity.isAlive()) {
type = entity.toString();
id = entity.getTypeId();
// using breeder finder
if (actionT == ActionType.BREED)
Jobs.getGCManager().setBreederFinder(true);
}
switch (key.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 (actionT == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey);
if (enchant != null)
id = enchant.getId();
type = myKey;
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL) {
type = myKey;
} else if (actionT == ActionType.EXPLORE) {
type = myKey;
int amount = 10;
try {
amount = Integer.valueOf(myKey);
} catch (NumberFormatException e) {
player.sendMessage("Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
break;
}
Jobs.getExplore().setExploreEnabled();
Jobs.getExplore().setPlayerAmount(amount + 1);
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!")) {
type = myKey.substring(1, myKey.length());
}
if (type == null) {
player.sendMessage("Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
break;
}
if (actionT == ActionType.TNTBREAK)
Jobs.getGCManager().setTntFinder(true);
double income = 0D;
double points = 0D;
double experience = 0D;
int fromlevel = 1;
int untilLevel = -1;
JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel,
untilLevel, "Jobs/" + job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-"));
for (JobInfo info : job.getJobInfo(actionT)) {
if (info.getName().equalsIgnoreCase(jInfo.getName())) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
action.add(jInfo);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath() + "/income", 0);
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath() + "/points", 0);
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath() + "/experience", 0);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
}
return true;
}
private void showPath(Player player, Job job, ActionType action, JobInfo jInfo) {
RawMessage rm = new RawMessage();
rm.add("&eJobs:", "&eJob list", "jobs editjobs");
rm.show(player);
if (job != null) {
rm = new RawMessage();
rm.add(" -> [" + job.getChatColor() + job.getName() + "&r]", job.getName(), "jobs editjobs list " + job.getName());
rm.show(player);
}
if (action != null && job != null) {
rm = new RawMessage();
rm.add(" -> &e[&6" + action.getName() + "&e]", action.getName(), "jobs editjobs list " + job.getName() + " " + action.getName());
rm.show(player);
}
if (action != null && job != null && jInfo != null) {
rm = new RawMessage();
String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().Translate(materialName, jInfo);
materialName = org.bukkit.ChatColor.translateAlternateColorCodes('&', materialName);
rm.add(" -> &e[&6" + jInfo.getName() + "&e]", jInfo.getName(), "jobs editjobs list " + job.getName() + " " + action.getName() + " " + materialName);
rm.show(player);
}
}
}

View File

@ -20,8 +20,10 @@ package com.gamingmesh.jobs.config;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -36,7 +38,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CmiItems.ItemManager.CMIEntityType;
import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.BoostMultiplier;
import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.CurrencyType;
@ -50,7 +51,6 @@ import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.container.JobPermission; import com.gamingmesh.jobs.container.JobPermission;
import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
public class ConfigManager { public class ConfigManager {
private Jobs plugin; private Jobs plugin;
@ -64,6 +64,61 @@ public class ConfigManager {
loadJobSettings(); loadJobSettings();
} }
public void changeJobsSettings(String path, Object value) {
File f = new File(plugin.getDataFolder(), "jobConfig.yml");
InputStreamReader s = null;
try {
s = new InputStreamReader(new FileInputStream(f), "UTF-8");
} catch (UnsupportedEncodingException | FileNotFoundException e1) {
e1.printStackTrace();
}
if (!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!");
try {
if (s != null)
s.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return;
}
}
YamlConfiguration conf = new YamlConfiguration();
conf.options().pathSeparator('/');
try {
conf.load(s);
if (s != null)
s.close();
} catch (Exception e) {
Bukkit.getServer().getLogger().severe("==================== Jobs ====================");
Bukkit.getServer().getLogger().severe("Unable to load jobConfig.yml!");
Bukkit.getServer().getLogger().severe("Check your config for formatting issues!");
Bukkit.getServer().getLogger().severe("No jobs were loaded!");
Bukkit.getServer().getLogger().severe("Error: " + e.getMessage());
Bukkit.getServer().getLogger().severe("==============================================");
return;
} finally {
if (s != null)
try {
s.close();
} catch (IOException e) {
e.printStackTrace();
}
}
conf.set(path, value);
try {
conf.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
/** /**
* Method to load the jobs configuration * Method to load the jobs configuration
* *
@ -419,6 +474,10 @@ public class ConfigManager {
Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand, Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar); jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar);
job.setMoneyEquation(incomeEquation);
job.setXpEquation(expEquation);
job.setPointsEquation(pointsEquation);
for (ActionType actionType : ActionType.values()) { for (ActionType actionType : ActionType.values()) {
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName()); ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
ArrayList<JobInfo> jobInfo = new ArrayList<JobInfo>(); ArrayList<JobInfo> jobInfo = new ArrayList<JobInfo>();
@ -621,7 +680,7 @@ public class ConfigManager {
} }
jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, pointsEquation, points, fromlevel, jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, pointsEquation, points, fromlevel,
untilLevel)); untilLevel, section.getCurrentPath()));
} }
} }
job.setJobInfo(actionType, jobInfo); job.setJobInfo(actionType, jobInfo);

View File

@ -40,6 +40,7 @@ public enum ActionType {
CUSTOMKILL("custom-kill"); CUSTOMKILL("custom-kill");
private String name; private String name;
private ActionType(String name) { private ActionType(String name) {
this.name = name; this.name = name;
} }
@ -47,4 +48,13 @@ public enum ActionType {
public String getName() { public String getName() {
return name; return name;
} }
public static ActionType getByName(String name) {
name = name.replace("_", "");
for (ActionType one : ActionType.values()) {
if (one.name.equalsIgnoreCase(name))
return one;
}
return null;
}
} }

View File

@ -73,6 +73,8 @@ public class Job {
private BoostMultiplier boost = new BoostMultiplier(); private BoostMultiplier boost = new BoostMultiplier();
private String bossbar; private String bossbar;
private Parser moneyEquation, xpEquation, pointsEquation;
/** /**
* Constructor * Constructor
* @param jobName - the name of the job * @param jobName - the name of the job
@ -195,7 +197,7 @@ public class Job {
*/ */
public List<JobInfo> getJobInfo(ActionType type) { public List<JobInfo> getJobInfo(ActionType type) {
return Collections.unmodifiableList(jobInfo.get(type)); return jobInfo.get(type);
} }
/** /**
@ -352,4 +354,28 @@ public class Job {
public void setBossbar(String bossbar) { public void setBossbar(String bossbar) {
this.bossbar = bossbar; this.bossbar = bossbar;
} }
public Parser getMoneyEquation() {
return moneyEquation;
}
public void setMoneyEquation(Parser moneyEquation) {
this.moneyEquation = moneyEquation;
}
public Parser getXpEquation() {
return xpEquation;
}
public void setXpEquation(Parser xpEquation) {
this.xpEquation = xpEquation;
}
public Parser getPointsEquation() {
return pointsEquation;
}
public void setPointsEquation(Parser pointsEquation) {
this.pointsEquation = pointsEquation;
}
} }

View File

@ -31,8 +31,10 @@ public class JobInfo {
private int fromLevel = 0; private int fromLevel = 0;
private int untilLevel = Integer.MAX_VALUE; private int untilLevel = Integer.MAX_VALUE;
private String configPath = "";
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,
Parser pointsEquation, double basePoints, int fromLevel, int untilLevel) { Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath) {
this.actionType = actionType; this.actionType = actionType;
this.id = id; this.id = id;
this.meta = meta; this.meta = meta;
@ -45,6 +47,7 @@ public class JobInfo {
this.xpEquation = xpEquation; this.xpEquation = xpEquation;
this.fromLevel = fromLevel; this.fromLevel = fromLevel;
this.untilLevel = untilLevel; this.untilLevel = untilLevel;
this.configPath = configPath;
} }
@ -114,4 +117,24 @@ public class JobInfo {
pointsEquation.setVariable("basepoints", basePoints); pointsEquation.setVariable("basepoints", basePoints);
return pointsEquation.getValue(); return pointsEquation.getValue();
} }
public String getConfigPath() {
return configPath;
}
public void setConfigPath(String configPath) {
this.configPath = configPath;
}
public void setBaseIncome(double baseIncome) {
this.baseIncome = baseIncome;
}
public void setBaseXp(double baseXp) {
this.baseXp = baseXp;
}
public void setBasePoints(double basePoints) {
this.basePoints = basePoints;
}
} }

View File

@ -69,7 +69,7 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobLimitedItems; import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Util;
public class JobsListener implements Listener { public class JobsListener implements Listener {
// hook to the main plugin // hook to the main plugin
@ -81,6 +81,27 @@ public class JobsListener implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.NORMAL)
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
if (event.isCancelled())
return;
if (Util.getJobsEditorMap().isEmpty())
return;
Player player = event.getPlayer();
if (!Util.getJobsEditorMap().containsKey(player.getUniqueId()))
return;
String msg = Util.getJobsEditorMap().remove(player.getUniqueId());
if (msg == null)
return;
player.performCommand(msg + event.getMessage());
event.setCancelled(true);
}
private boolean isInteractOk(Player player) { private boolean isInteractOk(Player player) {
if (!interactDelay.containsKey(player.getUniqueId())) { if (!interactDelay.containsKey(player.getUniqueId())) {
interactDelay.put(player.getUniqueId(), System.currentTimeMillis()); interactDelay.put(player.getUniqueId(), System.currentTimeMillis());

View File

@ -1,5 +1,8 @@
package com.gamingmesh.jobs.stuff; package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
@ -15,6 +18,8 @@ public class Util {
public Util() { public Util() {
} }
private static HashMap<UUID, String> jobsEditorMap = new HashMap<UUID, String>();
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException { public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException {
boolean useMeta; boolean useMeta;
@ -53,4 +58,8 @@ public class Util {
} }
return EntityType.fromId(is.getData().getData()); return EntityType.fromId(is.getData().getData());
} }
public static HashMap<UUID, String> getJobsEditorMap() {
return jobsEditorMap;
}
} }