1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 15:03:36 +01:00

Update all signs on player doing something in a job

This commit is contained in:
montlikadani 2020-03-21 15:13:47 +01:00
parent 9fa5dfb2aa
commit f6bd87fe4c
3 changed files with 22 additions and 28 deletions

View File

@ -44,7 +44,6 @@ import org.bukkit.inventory.meta.FireworkMeta;
import com.gamingmesh.jobs.CMILib.ItemReflection; import com.gamingmesh.jobs.CMILib.ItemReflection;
import com.gamingmesh.jobs.CMILib.Reflections; import com.gamingmesh.jobs.CMILib.Reflections;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version; import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.Signs.SignTopType;
import com.gamingmesh.jobs.api.JobsJoinEvent; import com.gamingmesh.jobs.api.JobsJoinEvent;
import com.gamingmesh.jobs.api.JobsLeaveEvent; import com.gamingmesh.jobs.api.JobsLeaveEvent;
import com.gamingmesh.jobs.api.JobsLevelUpEvent; import com.gamingmesh.jobs.api.JobsLevelUpEvent;
@ -392,9 +391,10 @@ public class PlayerManager {
Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job)); Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job));
PerformCommands.PerformCommandsOnJoin(jPlayer, job); PerformCommands.PerformCommandsOnJoin(jPlayer, job);
Jobs.takeSlot(job); Jobs.takeSlot(job);
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
job.updateTotalPlayers(); job.updateTotalPlayers();
} }
@ -423,8 +423,7 @@ public class PlayerManager {
PerformCommands.PerformCommandsOnLeave(jPlayer, job); PerformCommands.PerformCommandsOnLeave(jPlayer, job);
Jobs.leaveSlot(job); Jobs.leaveSlot(job);
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
job.updateTotalPlayers(); job.updateTotalPlayers();
return true; return true;
} }
@ -471,8 +470,7 @@ public class PlayerManager {
jPlayer.promoteJob(job, levels); jPlayer.promoteJob(job, levels);
jPlayer.save(); jPlayer.save();
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
} }
/** /**
@ -484,8 +482,8 @@ public class PlayerManager {
public void demoteJob(JobsPlayer jPlayer, Job job, int levels) { public void demoteJob(JobsPlayer jPlayer, Job job, int levels) {
jPlayer.demoteJob(job, levels); jPlayer.demoteJob(job, levels);
jPlayer.save(); jPlayer.save();
Jobs.getSignUtil().SignUpdate(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist); Jobs.getSignUtil().updateAllSign(job);
} }
/** /**
@ -501,8 +499,7 @@ public class PlayerManager {
int oldLevel = prog.getLevel(); int oldLevel = prog.getLevel();
if (prog.addExperience(experience)) { if (prog.addExperience(experience)) {
performLevelUp(jPlayer, job, oldLevel); performLevelUp(jPlayer, job, oldLevel);
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
} }
jPlayer.save(); jPlayer.save();
@ -521,8 +518,7 @@ public class PlayerManager {
prog.addExperience(-experience); prog.addExperience(-experience);
jPlayer.save(); jPlayer.save();
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
} }
/** /**
@ -564,8 +560,7 @@ public class PlayerManager {
jPlayer.reloadHonorific(); jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer); Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel); performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
return; return;
} }
@ -761,8 +756,7 @@ public class PlayerManager {
jPlayer.reloadHonorific(); jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer); Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel); performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
Jobs.getSignUtil().SignUpdate(job); Jobs.getSignUtil().updateAllSign(job);
Jobs.getSignUtil().SignUpdate(job, SignTopType.gtoplist);
} }
/** /**

View File

@ -162,6 +162,12 @@ public class SignUtil {
} }
} }
public void updateAllSign(Job job) {
for (SignTopType types : SignTopType.values()) {
SignUpdate(job, types);
}
}
public boolean SignUpdate(Job job) { public boolean SignUpdate(Job job) {
return SignUpdate(job, SignTopType.toplist); return SignUpdate(job, SignTopType.toplist);
} }

View File

@ -49,16 +49,12 @@ public class join implements Cmd {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); 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"); pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getChatColor() + job.getName()));
message = message.replace("%jobname%", job.getChatColor() + job.getName());
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"); pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getChatColor() + job.getName()));
message = message.replace("%jobname%", job.getChatColor() + job.getName());
pSender.sendMessage(message);
return true; return true;
} }
@ -71,7 +67,8 @@ public class join implements Cmd {
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(pSender); rm.show(pSender);
return true; return true;
} }
@ -85,10 +82,7 @@ public class join implements Cmd {
} }
Jobs.getPlayerManager().joinJob(jPlayer, job); Jobs.getPlayerManager().joinJob(jPlayer, job);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getChatColor() + job.getName()));
String message = Jobs.getLanguage().getMessage("command.join.success");
message = message.replace("%jobname%", job.getChatColor() + job.getName());
pSender.sendMessage(message);
return true; return true;
} }
} }