1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00
This commit is contained in:
montlikadani 2019-10-06 17:51:11 +02:00
parent 51742dc97d
commit d9beab45da
4 changed files with 18 additions and 24 deletions

View File

@ -33,55 +33,53 @@ public class join implements Cmd {
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
String jobName = args[0];
Job job = Jobs.getJob(jobName);
Job job = Jobs.getJob(args[0]);
if (job == null) {
// job does not exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
if (!Jobs.getCommandManager().hasJobPermission(pSender, job)) {
// you do not have permission to join the job
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer.isInJob(job)) {
// already in job message
String message = Jobs.getLanguage().getMessage("command.join.error.alreadyin");
message = message.replace("%jobname%", job.getChatColor() + job.getName());
sender.sendMessage(message);
pSender.sendMessage(message);
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = Jobs.getLanguage().getMessage("command.join.error.fullslots");
message = message.replace("%jobname%", job.getChatColor() + job.getName());
sender.sendMessage(message);
pSender.sendMessage(message);
return true;
}
int confMaxJobs = Jobs.getGCManager().getMaxJobs();
short PlayerMaxJobs = (short) jPlayer.getJobProgression().size();
if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(jPlayer, PlayerMaxJobs)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.maxjobs"));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.maxjobs"));
return true;
}
if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()), Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()), "jobs join " + job.getName());
rm.show(sender);
rm.show(pSender);
return true;
}
JobProgression ajp = jPlayer.getArchivedJobProgression(job);
if (ajp != null) {
if (!ajp.canRejoin()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage()));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage()));
return true;
}
}
@ -90,7 +88,7 @@ public class join implements Cmd {
String message = Jobs.getLanguage().getMessage("command.join.success");
message = message.replace("%jobname%", job.getChatColor() + job.getName());
sender.sendMessage(message);
pSender.sendMessage(message);
return true;
}
}

View File

@ -342,9 +342,6 @@ public class ConfigManager {
meta = "1";
break;
default:
type = CMIEntityType.getByName(myKey.toUpperCase()).name();
id = CMIEntityType.getByName(myKey.toUpperCase()).getId();
meta = "1";
break;
}
}
@ -400,8 +397,9 @@ public class ConfigManager {
InputStreamReader s = new InputStreamReader(new FileInputStream(f), "UTF-8");
ArrayList<Job> jobs = new ArrayList<>();
Jobs.setJobs(jobs);
Jobs.setNoneJob(null);
if (!f.exists()) {
try {
f.createNewFile();
@ -1129,9 +1127,6 @@ public class ConfigManager {
meta = "1";
break;
default:
type = CMIEntityType.getByName(myKey.toUpperCase()).name();
id = CMIEntityType.getByName(myKey.toUpperCase()).getId();
meta = "1";
break;
}
}
@ -1211,6 +1206,8 @@ public class ConfigManager {
Jobs.setNoneJob(job);
else
jobs.add(job);
Jobs.setJobs(jobs);
}
Jobs.consoleMsg("&e[Jobs] Loaded " + Jobs.getJobs().size() + " jobs!");

View File

@ -1,6 +1,7 @@
package com.gamingmesh.jobs.config;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
@ -62,7 +63,7 @@ public class LanguageManager {
if (jarFile != null)
try {
jarFile.close();
} catch (Throwable e) {
} catch (IOException e) {
}
}
return listOfCommands;
@ -90,8 +91,7 @@ public class LanguageManager {
//Up to here.
String ls = Jobs.getGCManager().localeString;
if (ls == null || ls.equals(""))
if (ls.equals(""))
ls = "en";
languages.clear();

View File

@ -174,8 +174,7 @@ public class NameTranslatorManager {
synchronized void load() {
String ls = Jobs.getGCManager().localeString;
if (ls == null || ls.equals(""))
if (ls.equals(""))
return;
File file = new File(Jobs.getFolder(), "TranslatableWords.yml");