mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Added option to send title and chat message when a player reached the max level of a job
Closes #971
This commit is contained in:
parent
be86d3e845
commit
22d985f0b4
@ -43,6 +43,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
import com.gamingmesh.jobs.CMILib.TitleMessageManager;
|
||||
import com.gamingmesh.jobs.api.JobsJoinEvent;
|
||||
import com.gamingmesh.jobs.api.JobsLeaveEvent;
|
||||
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
|
||||
@ -583,11 +584,8 @@ public class PlayerManager {
|
||||
try {
|
||||
if (Jobs.getGCManager().SoundLevelupUse) {
|
||||
Sound sound = levelUpEvent.getSound();
|
||||
if (sound != null) {
|
||||
if (player != null)
|
||||
player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getSoundVolume(), levelUpEvent.getSoundPitch());
|
||||
} else
|
||||
Jobs.consoleMsg("[Jobs] Can't find sound by name: " + levelUpEvent.getTitleChangeSound().name() + ". Please update it");
|
||||
if (player != null)
|
||||
player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getSoundVolume(), levelUpEvent.getSoundPitch());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@ -714,12 +712,9 @@ public class PlayerManager {
|
||||
try {
|
||||
if (Jobs.getGCManager().SoundTitleChangeUse) {
|
||||
Sound sound = levelUpEvent.getTitleChangeSound();
|
||||
if (sound != null) {
|
||||
if (player != null)
|
||||
player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getTitleChangeVolume(),
|
||||
levelUpEvent.getTitleChangePitch());
|
||||
} else
|
||||
Jobs.consoleMsg("[Jobs] Can't find sound by name: " + levelUpEvent.getTitleChangeSound().name() + ". Please update it");
|
||||
if (player != null)
|
||||
player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getTitleChangeVolume(),
|
||||
levelUpEvent.getTitleChangePitch());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@ -744,10 +739,18 @@ public class PlayerManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jPlayer.reloadHonorific();
|
||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||
Jobs.getSignUtil().updateAllSign(job);
|
||||
|
||||
if (Jobs.getGCManager().titleMessageMaxLevelReached && prog.getLevel() == jPlayer.getMaxJobLevelAllowed(prog.getJob())) {
|
||||
TitleMessageManager.send(jPlayer.getPlayer(), Jobs.getLanguage().getMessage("message.max-level-reached.title",
|
||||
"%jobname%", prog.getJob().getNameWithColor()),
|
||||
Jobs.getLanguage().getMessage("message.max-level-reached.subtitle", "%jobname%", prog.getJob().getNameWithColor()), 20, 40, 20);
|
||||
jPlayer.getPlayer().sendMessage(Jobs.getLanguage().getMessage("message.max-level-reached.chat", "%jobname%", prog.getJob().getNameWithColor()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -408,14 +408,18 @@ public class JobsCommands implements CommandExecutor {
|
||||
* @return the message
|
||||
*/
|
||||
public String jobStatsMessage(JobProgression jobProg) {
|
||||
boolean isMaxLevelReached = jobProg.getLevel() == jobProg.getJob().getMaxLevel();
|
||||
String path = "command.stats.output." + (isMaxLevelReached ? "max-level"
|
||||
: "message");
|
||||
|
||||
Title title = Jobs.gettitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
|
||||
String message = Jobs.getLanguage().getMessage("command.stats.output",
|
||||
String message = Jobs.getLanguage().getMessage(path,
|
||||
"%joblevel%", jobProg.getLevel(),
|
||||
"%jobname%", jobProg.getJob().getNameWithColor(),
|
||||
"%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0,
|
||||
"%jobmaxxp%", jobProg.getMaxExperience(),
|
||||
"%titlename%", title == null ? "Unknown" : title.getName());
|
||||
return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message;
|
||||
return " " + (isMaxLevelReached ? "" : jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience())) + " " + message;
|
||||
}
|
||||
|
||||
public String jobProgressMessage(double max, double current) {
|
||||
|
@ -100,9 +100,7 @@ public class quests implements Cmd {
|
||||
.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
||||
|
||||
if (current.contains("[desc]")) {
|
||||
for (String one : q.getQuest().getDescription()) {
|
||||
hoverList.add(one);
|
||||
}
|
||||
q.getQuest().getDescription().forEach(hoverList::add);
|
||||
} else {
|
||||
hoverList.add(current);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class GeneralConfigManager {
|
||||
BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities,
|
||||
payForEachVTradeItem;
|
||||
payForEachVTradeItem, titleMessageMaxLevelReached;
|
||||
|
||||
public ItemStack guiBackButton, guiNextButton, guiFiller;
|
||||
|
||||
@ -864,6 +864,9 @@ public class GeneralConfigManager {
|
||||
LevelChangeChat = c.get("ShowChatMessage.OnLevelChange", true);
|
||||
EmptyServerAccountChat = c.get("ShowChatMessage.OnEmptyServerAccount", true);
|
||||
|
||||
c.addComment("SendTitleMessageWhenMaxLevelReached", "Send title and chat message when a player reached the maximum level in a job.");
|
||||
titleMessageMaxLevelReached = c.get("SendTitleMessageWhenMaxLevelReached", false);
|
||||
|
||||
c.addComment("Sounds", "Sounds", "Extra sounds on some events",
|
||||
"All sounds can be found in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html");
|
||||
SoundLevelupUse = c.get("Sounds.LevelUp.use", true);
|
||||
|
@ -293,7 +293,8 @@ public class LanguageManager {
|
||||
c.get("command.stats.help.args", "[playername]");
|
||||
Jobs.getGCManager().getCommandArgs().put("stats", Arrays.asList("[playername]"));
|
||||
c.get("command.stats.error.nojob", "Please join a job first.");
|
||||
c.get("command.stats.output", "Level %joblevel% for %jobname%: %jobxp%/%jobmaxxp% xp");
|
||||
c.get("command.stats.output.message", "Level %joblevel% for %jobname%: %jobxp%/%jobmaxxp% xp");
|
||||
c.get("command.stats.output.max-level", " &cMax level - %jobname%");
|
||||
c.get("command.stats.bossBarOutput", "Lvl %joblevel% %jobname%: %jobxp%/%jobmaxxp% xp%gain%");
|
||||
c.get("command.stats.bossBarGain", " &7(&f%gain%&7)");
|
||||
|
||||
@ -631,6 +632,9 @@ public class LanguageManager {
|
||||
|
||||
c.get("message.skillup.broadcast", "%playername% has been promoted to a %titlename% %jobname%.");
|
||||
c.get("message.skillup.nobroadcast", "Congratulations, you have been promoted to a %titlename% %jobname%.");
|
||||
c.get("message.max-level-reached.title", "&2Max level reached");
|
||||
c.get("message.max-level-reached.subtitle", "&2in %jobname%!");
|
||||
c.get("message.max-level-reached.chat", "&cYou have reached the maximum level in %jobname%!");
|
||||
|
||||
c.get("message.levelup.broadcast", "%playername% is now a level %joblevel% %jobname%.");
|
||||
c.get("message.levelup.nobroadcast", "You are now level %joblevel% %jobname%.");
|
||||
|
@ -350,12 +350,12 @@ public class Job {
|
||||
}
|
||||
|
||||
public int getMaxLevel(JobsPlayer player) {
|
||||
return player == null ? getMaxLevel() : player.getMaxJobLevelAllowed(this);
|
||||
return player == null ? maxLevel : player.getMaxJobLevelAllowed(this);
|
||||
}
|
||||
|
||||
public int getMaxLevel(CommandSender sender) {
|
||||
if (sender == null)
|
||||
return getMaxLevel();
|
||||
return maxLevel;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
JobsPlayer player = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
@ -363,7 +363,7 @@ public class Job {
|
||||
return player.getMaxJobLevelAllowed(this);
|
||||
}
|
||||
|
||||
return getMaxLevel() > getVipMaxLevel() ? getMaxLevel() : getVipMaxLevel();
|
||||
return maxLevel > vipmaxLevel ? maxLevel : vipmaxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user