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

View File

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

View File

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

View File

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