1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Roman numbers

This commit is contained in:
Zrips 2021-09-13 17:01:41 +03:00
parent 0100f78c8b
commit 493f94264d
8 changed files with 51 additions and 9 deletions

View File

@ -534,7 +534,7 @@ public class Placeholder {
for (TopList l : Jobs.getJobsDAO().getGlobalTopList(jobLevel.get())) {
if (l.getPlayerInfo().getName().equals(user.getName())) {
JobProgression prog = l.getPlayerInfo().getJobsPlayer().getJobProgression(job);
return prog == null ? "" : Integer.toString(prog.getLevel());
return prog == null ? "" : prog.getLevelFormatted();
}
}
@ -555,7 +555,7 @@ public class Placeholder {
}
JobProgression archivedJobProg = user.getArchivedJobProgression(job);
return archivedJobProg == null ? "" : Integer.toString(archivedJobProg.getLevel());
return archivedJobProg == null ? "" : archivedJobProg.getLevelFormatted();
case user_archived_jobs_exp_$1:
if (job == null)
return "";

View File

@ -677,7 +677,7 @@ public class PlayerManager {
message = message.replace("%jobname%", job.getJobDisplayName());
message = message.replace("%playername%", player != null ? plugin.getComplement().getDisplayName(player) : jPlayer.getName());
message = message.replace("%joblevel%", Integer.toString(prog.getLevel()));
message = message.replace("%joblevel%", prog.getLevelFormatted());
message = message.replace("%lostLevel%", Integer.toString(oldLevel));
if (player != null && (Jobs.getGCManager().LevelChangeActionBar || Jobs.getGCManager().LevelChangeChat)) {
@ -785,7 +785,7 @@ public class PlayerManager {
.getChatColor().toString() + levelUpEvent.getOldTitle().getName());
message = message.replace("%playername%", player != null ? plugin.getComplement().getDisplayName(player) : jPlayer.getName());
message = message.replace("%joblevel%", Integer.toString(prog.getLevel()));
message = message.replace("%joblevel%", prog.getLevelFormatted());
if (Jobs.getGCManager().isBroadcastingLevelups() || Jobs.getGCManager().LevelChangeActionBar || Jobs.getGCManager().LevelChangeChat) {
for (String line : message.split("\n")) {

View File

@ -393,7 +393,7 @@ public class JobsCommands implements CommandExecutor {
Title title = Jobs.getTitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
String message = Jobs.getLanguage().getMessage(path,
"%joblevel%", jobProg.getLevel(),
"%joblevel%", jobProg.getLevelFormatted(),
"%jobname%", jobProg.getJob().getJobDisplayName(),
"%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0,
"%jobmaxxp%", jobProg.getMaxExperience(),

View File

@ -81,7 +81,7 @@ public class exp implements Cmd {
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getJobDisplayName(), "%level%", prog.getLevel(), "%exp%", prog
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getJobDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} else

View File

@ -65,7 +65,7 @@ public class BossBarManager {
}
String message = Jobs.getLanguage().getMessage("command.stats.bossBarOutput",
"%joblevel%", Integer.toString(jobProg.getLevel()),
"%joblevel%", jobProg.getLevelFormatted(),
"%jobname%", jobProg.getJob().getJobDisplayName(),
"%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0),
"%jobmaxxp%", jobProg.getMaxExperience(),

View File

@ -97,7 +97,7 @@ public class GeneralConfigManager {
JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, ShowActionNames, hideItemAttributes,
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve,
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel,
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers,
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
@ -376,6 +376,9 @@ public class GeneralConfigManager {
"ATTENTION! Set it to true only if you certain that commands performed on level up will not cause issues if player start level and delevel in a row.");
AllowDelevel = c.get("Optimizations.AllowDelevel", false);
c.addComment("Optimizations.RomanNumbers", "Enabling this option some places will indicate players level as XIV instead of 14", "Only or player levels");
RomanNumbers = c.get("Optimizations.RomanNumbers", false);
// c.addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files",
// "This will eliminate small lag spikes when request is being send to mojangs servers for offline players data",
// "Theroticali this should work without issues, but if you havving some, just disable",

View File

@ -21,7 +21,9 @@ package com.gamingmesh.jobs.container;
import java.util.HashMap;
import java.util.Map;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util;
public class JobProgression {
private Job job;
@ -136,6 +138,16 @@ public class JobProgression {
return level;
}
/**
* Get the current level of this job in formatted way
* @return the level of this job
*/
public String getLevelFormatted() {
if (Jobs.getGCManager().RomanNumbers)
return Util.toRoman(level);
return String.valueOf(level);
}
/**
* Sets the level of this job progression
*

View File

@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@ -48,6 +49,32 @@ public final class Util {
public static final List<UUID> LEAVECONFIRM = new ArrayList<>();
private final static TreeMap<Integer, String> map = new TreeMap<Integer, String>();
static {
map.put(1000, "M");
map.put(900, "CM");
map.put(500, "D");
map.put(400, "CD");
map.put(100, "C");
map.put(90, "XC");
map.put(50, "L");
map.put(40, "XL");
map.put(10, "X");
map.put(9, "IX");
map.put(5, "V");
map.put(4, "IV");
map.put(1, "I");
}
public final static String toRoman(int number) {
int l = map.floorKey(number);
if (number == l) {
return map.get(number);
}
return map.get(l) + toRoman(number - l);
}
public static List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
if (Version.isCurrentEqualOrHigher(Version.v1_8_R1)) {
return new ArrayList<>(event.getBlocks());
@ -101,7 +128,7 @@ public final class Util {
if (zombie.getVillagerProfession().toString().equals("HUSK"))
return "ZombieHusk";
} else if (zombie.isVillager()) {
return "ZombieVillager";
return "ZombieVillager";
}
break;