mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Split boost times and add info about timed boosts
This commit is contained in:
parent
e560b9328f
commit
e933bc3a84
@ -9,6 +9,7 @@ import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gamingmesh.jobs.container.Potion;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class ItemManager {
|
||||
@ -50,7 +51,11 @@ public class ItemManager {
|
||||
mojangName = mojangName == null ? mat.toString().replace("_", "").replace(" ", "").toLowerCase()
|
||||
: mojangName.replace("_", "").replace(" ", "").toLowerCase();
|
||||
|
||||
if (byName.containsKey(cmiName)) {
|
||||
if (one.isCanHavePotionType()) {
|
||||
for (Potion p : Potion.values()) {
|
||||
byName.put(cmiName + ":" + p.toString().toLowerCase(), one);
|
||||
}
|
||||
} else if (byName.containsKey(cmiName)) {
|
||||
byName.put(cmiName + ":" + data, one);
|
||||
} else
|
||||
byName.put(cmiName, one);
|
||||
@ -92,7 +97,6 @@ public class ItemManager {
|
||||
if (one.getLegacyData() == 0)
|
||||
byId.put(one.getLegacyId(), one);
|
||||
byRealMaterial.put(mat, one);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,7 +210,7 @@ public class ItemManager {
|
||||
cmat = CMIMaterial.get(name);
|
||||
}
|
||||
|
||||
if (cmat != null && !cmat.equals(CMIMaterial.NONE)) {
|
||||
if (cmat != null && cmat != CMIMaterial.NONE) {
|
||||
cm = cmat.newCMIItemStack();
|
||||
} else
|
||||
cmat = CMIMaterial.get(subdata == null ? original : original + ":" + subdata);
|
||||
|
@ -18,91 +18,44 @@ public class expboost implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
String time = "";
|
||||
double rate = 1.0;
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
if (args.length > 2) {
|
||||
time = args[1].toLowerCase();
|
||||
|
||||
try {
|
||||
rate = Double.parseDouble(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
rate = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length > 2) {
|
||||
int sec = 0, min = 0, hour = 0;
|
||||
|
||||
if (!time.isEmpty()) {
|
||||
if (time.contains("s")) {
|
||||
sec = Integer.parseInt(time.split("s")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m")) {
|
||||
min = Integer.parseInt(time.split("m")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h")) {
|
||||
hour = Integer.parseInt(time.split("h")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
boolean succeed = false;
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
if (time.isEmpty()) {
|
||||
one.addBoost(CurrencyType.EXP, rate);
|
||||
succeed = true;
|
||||
} else if (sec != 0 || min != 0 || hour != 0) {
|
||||
one.addBoost(CurrencyType.EXP, rate, hour, min, sec);
|
||||
succeed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (succeed) {
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
job.addBoost(CurrencyType.EXP, rate);
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
|
||||
try {
|
||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
one.addBoost(CurrencyType.EXP, 1.0);
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
job.addBoost(CurrencyType.EXP, rate, parseTime(args));
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reset") && args.length > 1) {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
one.addBoost(CurrencyType.EXP, 1.0);
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
|
||||
} else if (args.length > 1) {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.EXP, 1.0);
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset",
|
||||
"%jobname%", job.getName()));
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.EXP, 1.0);
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%",
|
||||
job.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,50 +65,46 @@ public class expboost implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 2) {
|
||||
time = args[1].toLowerCase();
|
||||
|
||||
try {
|
||||
rate = Double.parseDouble(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
rate = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!time.isEmpty()) {
|
||||
int sec = 0, min = 0, hour = 0;
|
||||
|
||||
if (time.contains("s")) {
|
||||
sec = Integer.parseInt(time.split("s")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m")) {
|
||||
min = Integer.parseInt(time.split("m")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h")) {
|
||||
hour = Integer.parseInt(time.split("h")[0]);
|
||||
}
|
||||
|
||||
if (sec != 0 || min != 0 || hour != 0) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
|
||||
"%jobname%", job.getName()));
|
||||
job.addBoost(CurrencyType.EXP, rate, hour, min, sec);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.EXP, rate);
|
||||
job.addBoost(CurrencyType.EXP, rate, parseTime(args));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
|
||||
"%jobname%", job.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] parseTime(String[] args) {
|
||||
int[] arr = new int[3];
|
||||
if (args.length < 2) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
String time = args[1].toLowerCase();
|
||||
if (time.isEmpty()) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (time.contains("s") || time.contains("second")) {
|
||||
arr[0] = Integer.parseInt(time.split("s|second")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m") || time.contains("minute")) {
|
||||
arr[1] = Integer.parseInt(time.split("m|minute")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h") || time.contains("hour")) {
|
||||
arr[2] = Integer.parseInt(time.split("h|hour")[0]);
|
||||
}
|
||||
|
||||
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
|
||||
return new int[3];
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
@ -18,91 +18,44 @@ public class moneyboost implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
String time = "";
|
||||
double rate = 1.0;
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
if (args.length > 2) {
|
||||
time = args[1].toLowerCase();
|
||||
|
||||
try {
|
||||
rate = Double.parseDouble(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
rate = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length > 2) {
|
||||
int sec = 0, min = 0, hour = 0;
|
||||
|
||||
if (!time.isEmpty()) {
|
||||
if (time.contains("s")) {
|
||||
sec = Integer.parseInt(time.split("s")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m")) {
|
||||
min = Integer.parseInt(time.split("m")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h")) {
|
||||
hour = Integer.parseInt(time.split("h")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
boolean succeed = false;
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
if (time.isEmpty()) {
|
||||
one.addBoost(CurrencyType.MONEY, rate);
|
||||
succeed = true;
|
||||
} else if (sec != 0 || min != 0 || hour != 0) {
|
||||
one.addBoost(CurrencyType.MONEY, rate, hour, min, sec);
|
||||
succeed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (succeed) {
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
job.addBoost(CurrencyType.MONEY, rate);
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
|
||||
try {
|
||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
one.addBoost(CurrencyType.MONEY, 1.0);
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
job.addBoost(CurrencyType.MONEY, rate, parseTime(args));
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reset") && args.length > 1) {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
one.addBoost(CurrencyType.MONEY, 1.0);
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
|
||||
} else if (args.length > 1) {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.MONEY, 1.0);
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset",
|
||||
"%jobname%", job.getName()));
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.MONEY, 1.0);
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%",
|
||||
job.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,50 +65,46 @@ public class moneyboost implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 2) {
|
||||
time = args[1].toLowerCase();
|
||||
|
||||
try {
|
||||
rate = Double.parseDouble(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
rate = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!time.isEmpty()) {
|
||||
int sec = 0, min = 0, hour = 0;
|
||||
|
||||
if (time.contains("s")) {
|
||||
sec = Integer.parseInt(time.split("s")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m")) {
|
||||
min = Integer.parseInt(time.split("m")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h")) {
|
||||
hour = Integer.parseInt(time.split("h")[0]);
|
||||
}
|
||||
|
||||
if (sec != 0 || min != 0 || hour != 0) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%",
|
||||
rate, "%jobname%", job.getName()));
|
||||
job.addBoost(CurrencyType.MONEY, rate, hour, min, sec);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.MONEY, rate);
|
||||
job.addBoost(CurrencyType.MONEY, rate, parseTime(args));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
|
||||
"%jobname%", job.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] parseTime(String[] args) {
|
||||
int[] arr = new int[3];
|
||||
if (args.length < 2) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
String time = args[1].toLowerCase();
|
||||
if (time.isEmpty()) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (time.contains("s") || time.contains("second")) {
|
||||
arr[0] = Integer.parseInt(time.split("s|second")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m") || time.contains("minute")) {
|
||||
arr[1] = Integer.parseInt(time.split("m|minute")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h") || time.contains("hour")) {
|
||||
arr[2] = Integer.parseInt(time.split("h|hour")[0]);
|
||||
}
|
||||
|
||||
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
|
||||
return new int[3];
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
@ -18,91 +18,44 @@ public class pointboost implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
String time = "";
|
||||
double rate = 1.0;
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
if (args.length > 2) {
|
||||
time = args[1].toLowerCase();
|
||||
|
||||
try {
|
||||
rate = Double.parseDouble(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
rate = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length > 2) {
|
||||
int sec = 0, min = 0, hour = 0;
|
||||
|
||||
if (!time.isEmpty()) {
|
||||
if (time.contains("s")) {
|
||||
sec = Integer.parseInt(time.split("s")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m")) {
|
||||
min = Integer.parseInt(time.split("m")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h")) {
|
||||
hour = Integer.parseInt(time.split("h")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
boolean succeed = false;
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
if (time.isEmpty()) {
|
||||
one.addBoost(CurrencyType.POINTS, rate);
|
||||
succeed = true;
|
||||
} else if (sec != 0 || min != 0 || hour != 0) {
|
||||
one.addBoost(CurrencyType.POINTS, rate, hour, min, sec);
|
||||
succeed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (succeed) {
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
job.addBoost(CurrencyType.POINTS, rate);
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
|
||||
try {
|
||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
one.addBoost(CurrencyType.POINTS, 1.0);
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
job.addBoost(CurrencyType.POINTS, rate, parseTime(args));
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
|
||||
sender.sendMessage(
|
||||
Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reset") && args.length > 1) {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
one.addBoost(CurrencyType.POINTS, 1.0);
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
|
||||
} else if (args.length > 1) {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.POINTS, 1.0);
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset",
|
||||
"%jobname%", job.getName()));
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.POINTS, 1.0);
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%",
|
||||
job.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,50 +65,46 @@ public class pointboost implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 2) {
|
||||
time = args[1].toLowerCase();
|
||||
|
||||
try {
|
||||
rate = Double.parseDouble(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
rate = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!time.isEmpty()) {
|
||||
int sec = 0, min = 0, hour = 0;
|
||||
|
||||
if (time.contains("s")) {
|
||||
sec = Integer.parseInt(time.split("s")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m")) {
|
||||
min = Integer.parseInt(time.split("m")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h")) {
|
||||
hour = Integer.parseInt(time.split("h")[0]);
|
||||
}
|
||||
|
||||
if (sec != 0 || min != 0 || hour != 0) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%",
|
||||
rate, "%jobname%", job.getName()));
|
||||
job.addBoost(CurrencyType.POINTS, rate, hour, min, sec);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
job.addBoost(CurrencyType.POINTS, rate);
|
||||
job.addBoost(CurrencyType.POINTS, rate, parseTime(args));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate,
|
||||
"%jobname%", job.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] parseTime(String[] args) {
|
||||
int[] arr = new int[3];
|
||||
if (args.length < 2) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
String time = args[1].toLowerCase();
|
||||
if (time.isEmpty()) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (time.contains("s") || time.contains("second")) {
|
||||
arr[0] = Integer.parseInt(time.split("s|second")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("m") || time.contains("minute")) {
|
||||
arr[1] = Integer.parseInt(time.split("m|minute")[0]);
|
||||
}
|
||||
|
||||
if (time.contains("h") || time.contains("hour")) {
|
||||
arr[2] = Integer.parseInt(time.split("h|hour")[0]);
|
||||
}
|
||||
|
||||
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
|
||||
return new int[3];
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
@ -838,11 +838,13 @@ public class ConfigManager {
|
||||
String item = guiSection.getString("Item");
|
||||
String subType = "";
|
||||
|
||||
if (item.contains("-")) {
|
||||
// uses subType
|
||||
subType = ":" + item.split("-")[1];
|
||||
item = item.split("-")[0];
|
||||
}
|
||||
if (item.contains("-")) {
|
||||
// uses subType
|
||||
subType = ":" + item.split("-")[1];
|
||||
item = item.split("-")[0];
|
||||
} else if (item.contains(":")) { // when we uses tipped arrow effect types
|
||||
item = item.split(":")[0];
|
||||
}
|
||||
|
||||
CMIMaterial material = CMIMaterial.get(item + (subType));
|
||||
|
||||
@ -1051,7 +1053,7 @@ public class ConfigManager {
|
||||
itemSection.getStringList("lore").stream().map(CMIChatColor::translate).forEach(lore::add);
|
||||
|
||||
HashMap<Enchantment, Integer> enchants = new HashMap<>();
|
||||
if (itemSection.contains("enchants"))
|
||||
if (itemSection.isList("enchants"))
|
||||
for (String eachLine : itemSection.getStringList("enchants")) {
|
||||
if (!eachLine.contains("="))
|
||||
continue;
|
||||
|
@ -122,8 +122,8 @@ public class LanguageManager {
|
||||
c.get("command.help.output.nextPageGui", "&6Next Page");
|
||||
|
||||
c.get("command.moneyboost.help.info", "Boosts money gain for all players");
|
||||
c.get("command.moneyboost.help.args", "[jobname]/all/reset [rate]/all");
|
||||
Jobs.getGCManager().getCommandArgs().put("moneyboost", Arrays.asList("[jobname]", "[rate]"));
|
||||
c.get("command.moneyboost.help.args", "[jobname]/all/reset [time]/[rate]");
|
||||
Jobs.getGCManager().getCommandArgs().put("moneyboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%[rate]"));
|
||||
c.get("command.moneyboost.output.allreset", "All money boosts turned off");
|
||||
c.get("command.moneyboost.output.jobsboostreset", "Money boost has been turned off for %jobname%");
|
||||
c.get("command.moneyboost.output.nothingtoreset", "Nothing to reset");
|
||||
@ -132,8 +132,8 @@ public class LanguageManager {
|
||||
c.get("command.moneyboost.output.infostats", "&c-----> &aMoney rate x%boost% enabled&c <-------");
|
||||
|
||||
c.get("command.pointboost.help.info", "Boosts point gain for all players");
|
||||
c.get("command.pointboost.help.args", "[jobname]/all/reset [rate]/all");
|
||||
Jobs.getGCManager().getCommandArgs().put("pointboost", Arrays.asList("[jobname]", "[rate]"));
|
||||
c.get("command.pointboost.help.args", "[jobname]/all/reset [time]/[rate]");
|
||||
Jobs.getGCManager().getCommandArgs().put("pointboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%[rate]"));
|
||||
c.get("command.pointboost.output.allreset", "All point boosts turned off");
|
||||
c.get("command.pointboost.output.jobsboostreset", "Point boost has been turned off for %jobname%");
|
||||
c.get("command.pointboost.output.nothingtoreset", "Nothing to reset");
|
||||
@ -142,8 +142,8 @@ public class LanguageManager {
|
||||
c.get("command.pointboost.output.infostats", "&c-----> &aPoints rate x%boost% enabled&c <-------");
|
||||
|
||||
c.get("command.expboost.help.info", "Boosts exp gain for all players");
|
||||
c.get("command.expboost.help.args", "[jobname]/all/reset [rate]/all");
|
||||
Jobs.getGCManager().getCommandArgs().put("expboost", Arrays.asList("[jobname]", "[rate]"));
|
||||
c.get("command.expboost.help.args", "[jobname]/all/reset [time]/[rate]");
|
||||
Jobs.getGCManager().getCommandArgs().put("expboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%[rate]"));
|
||||
c.get("command.expboost.output.allreset", "All exp boosts turned off");
|
||||
c.get("command.expboost.output.jobsboostreset", "Exp boost has been turned off for %jobname%");
|
||||
c.get("command.expboost.output.nothingtoreset", "Nothing to reset");
|
||||
|
@ -83,7 +83,7 @@ public class NameTranslatorManager {
|
||||
return nameLs + ":" + nameMeta;
|
||||
}
|
||||
|
||||
if (mat.equals(CMIMaterial.NONE)) {
|
||||
if (mat == CMIMaterial.NONE) {
|
||||
return fallbackMaterialName;
|
||||
}
|
||||
|
||||
@ -106,11 +106,11 @@ public class NameTranslatorManager {
|
||||
case TAME:
|
||||
for (NameList one : ListOfEntities) {
|
||||
String ids = one.getId() + ":" + one.getMeta();
|
||||
if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equalsIgnoreCase("0")) {
|
||||
if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equals("0")) {
|
||||
return one.getName();
|
||||
}
|
||||
ids = one.getId();
|
||||
if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equalsIgnoreCase("0")) {
|
||||
if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equals("0")) {
|
||||
return one.getName();
|
||||
}
|
||||
ids = one.getMinecraftName();
|
||||
@ -391,9 +391,7 @@ public class NameTranslatorManager {
|
||||
}
|
||||
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
if (one == null)
|
||||
continue;
|
||||
if (CMIEnchantment.getName(one) == null)
|
||||
if (one == null || CMIEnchantment.getName(one) == null)
|
||||
continue;
|
||||
|
||||
String name = Util.firstToUpperCase(CMIEnchantment.getName(one).toString()).replace("_", " ");
|
||||
|
@ -116,13 +116,18 @@ public class Job {
|
||||
boost.add(type, Point);
|
||||
}
|
||||
|
||||
public void addBoost(CurrencyType type, double point, int hour, int minute, int second) {
|
||||
public void addBoost(CurrencyType type, double point, int[] times) {
|
||||
if (times.length < 3) {
|
||||
addBoost(type, point);
|
||||
return;
|
||||
}
|
||||
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + hour);
|
||||
cal.set(Calendar.MINUTE, cal.get(Calendar.MINUTE) + minute);
|
||||
cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + second);
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + times[2]);
|
||||
cal.set(Calendar.MINUTE, cal.get(Calendar.MINUTE) + times[1]);
|
||||
cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + times[0]);
|
||||
|
||||
long time = cal.getTimeInMillis();
|
||||
boost.add(type, point, time);
|
||||
|
@ -22,40 +22,30 @@ package com.gamingmesh.jobs.container;
|
||||
* <a href="https://papermc.io/javadocs/paper/1.13/org/bukkit/potion/PotionType.html">API reference for names</a>
|
||||
*/
|
||||
public enum Potion {
|
||||
AWKWARD("awkward"),
|
||||
FIRE_RESISTANCE("fire_resistance"),
|
||||
INSTANT_DAMAGE("instant_damage"),
|
||||
INSTANT_HEAL("instant_heal"),
|
||||
INVISIBILITY("invisibility"),
|
||||
JUMP("jump"),
|
||||
LUCK("luck"),
|
||||
MUNDANE("mundane"),
|
||||
NIGHT_VISION("night_vision"),
|
||||
LONG_NIGHT_VISION("long_night_vision"),
|
||||
POISON("poison"),
|
||||
REGENERATION("regeneration"),
|
||||
SLOW_FALLING("slow_falling"),
|
||||
SLOWNESS("slowness"),
|
||||
SPEED("speed"),
|
||||
STRENGTH("strength"),
|
||||
THICK("thick"),
|
||||
TURTLE_MASTER("turtle_master"),
|
||||
WATER_BREATHING("water_breathing"),
|
||||
WEAKNESS("weakness");
|
||||
|
||||
private final String name;
|
||||
|
||||
Potion(String name) {
|
||||
this.name = name.toUpperCase();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
AWKWARD,
|
||||
FIRE_RESISTANCE,
|
||||
INSTANT_DAMAGE,
|
||||
INSTANT_HEAL,
|
||||
INVISIBILITY,
|
||||
JUMP,
|
||||
LUCK,
|
||||
MUNDANE,
|
||||
NIGHT_VISION,
|
||||
LONG_NIGHT_VISION,
|
||||
POISON,
|
||||
REGENERATION,
|
||||
SLOW_FALLING,
|
||||
SLOWNESS,
|
||||
SPEED,
|
||||
STRENGTH,
|
||||
THICK,
|
||||
TURTLE_MASTER,
|
||||
WATER_BREATHING,
|
||||
WEAKNESS;
|
||||
|
||||
public static Potion getByName(String name) {
|
||||
for (Potion one : Potion.values()) {
|
||||
if (one.name.equalsIgnoreCase(name)) {
|
||||
if (one.toString().equalsIgnoreCase(name)) {
|
||||
return one;
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ public class TabComplete implements TabCompleter {
|
||||
List<String> temp = new ArrayList<>();
|
||||
for (String ar : t2) {
|
||||
switch (ar) {
|
||||
case "[time]":
|
||||
temp.add("1hour10minute20s");
|
||||
break;
|
||||
case "[questname]":
|
||||
case "[quest]":
|
||||
Job job = Jobs.getJob(args[i - 1]);
|
||||
|
Loading…
Reference in New Issue
Block a user