1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Re-worked the quest list to support crowdin

- Fixed %titlename% placeholder does not showed anything
- Re-added Cat, Cat is ALIVE!!
This commit is contained in:
montlikadani 2019-08-19 18:31:29 +02:00
parent c5d967a2f1
commit 88c6d1fc38
11 changed files with 59 additions and 77 deletions

View File

@ -77,8 +77,8 @@
<!-- WorldGuard new version --> <!-- WorldGuard new version -->
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId> <artifactId>worldguard-bukkit</artifactId>
<version>7.0.0-SNAPSHOT</version> <version>7.0.1-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
@ -94,7 +94,7 @@
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>7.0.0-SNAPSHOT</version> <version>7.1.0-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
@ -109,7 +109,7 @@
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId> <artifactId>worldedit-core</artifactId>
<version>7.0.0-SNAPSHOT</version> <version>7.1.0-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>

View File

@ -132,7 +132,6 @@ public class ItemManager {
/** /**
* Gets the item by material * Gets the item by material
*
* @deprecated Use {@link #getItem(ItemStack)} * @deprecated Use {@link #getItem(ItemStack)}
* @param mat Material * @param mat Material
* @return {@link CMIItemStack} * @return {@link CMIItemStack}
@ -181,7 +180,7 @@ public class ItemManager {
String a = name.split("-")[1]; String a = name.split("-")[1];
try { try {
amount = Integer.parseInt(a); amount = Integer.parseInt(a);
} catch (Throwable e) { } catch (NumberFormatException e) {
} }
name = name.split("-")[0]; name = name.split("-")[0];
} }
@ -191,7 +190,7 @@ public class ItemManager {
if (name.contains(":")) { if (name.contains(":")) {
try { try {
data = (short) Integer.parseInt(name.split(":")[1]); data = (short) Integer.parseInt(name.split(":")[1]);
} catch (Throwable e) { } catch (NumberFormatException e) {
} }
try { try {
CMIEntityType e = CMIEntityType.getByName(name.split(":")[1]); CMIEntityType e = CMIEntityType.getByName(name.split(":")[1]);
@ -276,7 +275,7 @@ public class ItemManager {
if (cm == null) { if (cm == null) {
try { try {
cm = byId.get(Integer.parseInt(name)); cm = byId.get(Integer.parseInt(name));
} catch (Throwable e) { } catch (NumberFormatException e) {
} }
if (cm == null) { if (cm == null) {
@ -354,7 +353,7 @@ public class ItemManager {
if (ncm != null && subdata != null) { if (ncm != null && subdata != null) {
if (ncm.getCMIType().isPotion() || ncm.getCMIType().equals(CMIMaterial.SPLASH_POTION) || ncm.getCMIType().equals(CMIMaterial.TIPPED_ARROW)) { if (ncm.getCMIType().isPotion() || ncm.getCMIType().equals(CMIMaterial.TIPPED_ARROW)) {
Integer d = null; Integer d = null;
PotionEffectType type = null; PotionEffectType type = null;
Boolean upgraded = false; Boolean upgraded = false;
@ -632,6 +631,7 @@ public class ItemManager {
ENDERMITE(67, "Endermite"), ENDERMITE(67, "Endermite"),
GUARDIAN(68, "Guardian"), GUARDIAN(68, "Guardian"),
SHULKER(69, "Shulker"), SHULKER(69, "Shulker"),
CAT(75, "Cat"),
PIG(90, "Pig"), PIG(90, "Pig"),
SHEEP(91, "Sheep"), SHEEP(91, "Sheep"),
COW(92, "Cow"), COW(92, "Cow"),
@ -640,7 +640,7 @@ public class ItemManager {
WOLF(95, "Wolf"), WOLF(95, "Wolf"),
MUSHROOM_COW(96, "Mushroom Cow", "Mooshroom"), MUSHROOM_COW(96, "Mushroom Cow", "Mooshroom"),
SNOWMAN(97, "Snowman"), SNOWMAN(97, "Snowman"),
OCELOT(98, "Ocelot", "Cat"), OCELOT(98, "Ocelot"),
IRON_GOLEM(99, "Iron Golem"), IRON_GOLEM(99, "Iron Golem"),
HORSE(100, "Horse"), HORSE(100, "Horse"),
RABBIT(101, "Rabbit"), RABBIT(101, "Rabbit"),
@ -752,7 +752,7 @@ public class ItemManager {
Integer id = null; Integer id = null;
try { try {
id = Integer.parseInt(main); id = Integer.parseInt(main);
} catch (Exception e) { } catch (NumberFormatException e) {
} }
for (CMIEntityType one : CMIEntityType.values()) { for (CMIEntityType one : CMIEntityType.values()) {
@ -1910,7 +1910,6 @@ public class ItemManager {
/** /**
* Get the legacy id from the material enum * Get the legacy id from the material enum
*
* @deprecated Not used, above 1.13 * @deprecated Not used, above 1.13
* @return legacy id * @return legacy id
*/ */
@ -1921,7 +1920,6 @@ public class ItemManager {
/** /**
* Get the id from the material enum * Get the id from the material enum
*
* @deprecated If the id is exist under 1.13 then success * @deprecated If the id is exist under 1.13 then success
* @return id * @return id
*/ */
@ -1997,7 +1995,6 @@ public class ItemManager {
/** /**
* Get the data * Get the data
*
* @deprecated Not used, above 1.13+ * @deprecated Not used, above 1.13+
* @return data * @return data
*/ */
@ -2011,7 +2008,6 @@ public class ItemManager {
/** /**
* Get the legacy data * Get the legacy data
*
* @deprecated Not used, above 1.13+ * @deprecated Not used, above 1.13+
* @return legacy data * @return legacy data
*/ */
@ -2021,7 +2017,6 @@ public class ItemManager {
} }
public static CMIMaterial getRandom(CMIMaterial mat) { public static CMIMaterial getRandom(CMIMaterial mat) {
List<CMIMaterial> ls = new ArrayList<CMIMaterial>(); List<CMIMaterial> ls = new ArrayList<CMIMaterial>();
for (CMIMaterial one : CMIMaterial.values()) { for (CMIMaterial one : CMIMaterial.values()) {
@ -2077,7 +2072,7 @@ public class ItemManager {
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) { if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {
try { try {
ids = Integer.parseInt(id); ids = Integer.parseInt(id);
} catch (Throwable e) { } catch (NumberFormatException e) {
if (id.contains(":")) { if (id.contains(":")) {
try { try {
ids = Integer.parseInt(id.split(":")[0]); ids = Integer.parseInt(id.split(":")[0]);
@ -2089,7 +2084,7 @@ public class ItemManager {
try { try {
data = Integer.parseInt(id.split(":")[1]); data = Integer.parseInt(id.split(":")[1]);
id = id.split(":")[0]; id = id.split(":")[0];
} catch (Throwable t) { } catch (NumberFormatException t) {
} }
} }
} }

View File

@ -33,27 +33,27 @@ public class ItemReflection {
private static void initialize() { private static void initialize() {
try { try {
CraftServerClass = getBukkitClass("CraftServer"); CraftServerClass = getBukkitClass("CraftServer");
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
CraftServer = CraftServerClass.cast(Bukkit.getServer()); CraftServer = CraftServerClass.cast(Bukkit.getServer());
} catch (SecurityException | IllegalArgumentException e) { } catch (ClassCastException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
CraftItemStack = getBukkitClass("inventory.CraftItemStack"); CraftItemStack = getBukkitClass("inventory.CraftItemStack");
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
Item = getMinecraftClass("Item"); Item = getMinecraftClass("Item");
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
IStack = getMinecraftClass("ItemStack"); IStack = getMinecraftClass("ItemStack");
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -36,8 +36,9 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.stuff.PageInfo; import com.gamingmesh.jobs.stuff.PageInfo;
import com.gamingmesh.jobs.stuff.TimeManage;
public class JobsCommands implements CommandExecutor { public class JobsCommands implements CommandExecutor {
private static final String label = "jobs"; private static final String label = "jobs";
@ -488,17 +489,12 @@ public class JobsCommands implements CommandExecutor {
* @return the message * @return the message
*/ */
public String jobStatsMessage(JobProgression jobProg) { public String jobStatsMessage(JobProgression jobProg) {
Title t = null;
for (Title title : new ArrayList<Title>()) {
if (t == null)
t = title;
}
String message = Jobs.getLanguage().getMessage("command.stats.output", String message = Jobs.getLanguage().getMessage("command.stats.output",
"%joblevel%", jobProg.getLevel(), "%joblevel%", jobProg.getLevel(),
"%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(), "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(),
"%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0, "%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0,
"%jobmaxxp%", jobProg.getMaxExperience(), "%jobmaxxp%", jobProg.getMaxExperience(),
"%titlename%", t == null ? "" : t.getName()); "%titlename%", Jobs.gettitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName()).getName());
return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message; return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message;
} }
@ -539,4 +535,18 @@ public class JobsCommands implements CommandExecutor {
"%jobmaxxp%", jobProg.getMaxExperience(level)); "%jobmaxxp%", jobProg.getMaxExperience(level));
return " " + jobProgressMessage(jobProg.getMaxExperience(level), exp) + " " + message; return " " + jobProgressMessage(jobProg.getMaxExperience(level), exp) + " " + message;
} }
public String jobsQuestMessage(QuestProgression qp, JobProgression prog) {
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
hoverMsg = hoverMsg.replace("[jobName]", prog.getJob().getName())
.replace("[time]", TimeManage.to24hourShort(qp.getValidUntil() - System.currentTimeMillis()));
if (hoverMsg.contains("[desc]")) {
for (String one : qp.getQuest().getDescription()) {
hoverMsg = hoverMsg.replace("[desc]", one);
}
}
return hoverMsg;
}
} }

View File

@ -76,7 +76,7 @@ public class editjobs implements Cmd {
Integer page = null; Integer page = null;
try { try {
page = Integer.parseInt(args[3]); page = Integer.parseInt(args[3]);
} catch (Throwable e) { } catch (NumberFormatException e) {
} }
if (page != null) { if (page != null) {

View File

@ -55,7 +55,7 @@ public class exp implements Cmd {
double amount = 0.0; double amount = 0.0;
try { try {
amount = Double.parseDouble(args[3]); amount = Double.parseDouble(args[3]);
} catch (Throwable e) { } catch (NumberFormatException e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
return true; return true;
} }

View File

@ -27,12 +27,9 @@ public class expboost implements Cmd {
return true; return true;
} }
String PlayerName = sender.getName(); Job job = Jobs.getJob(args[0]);
String jobName = args[0]; if (job == null) {
Job job = Jobs.getJob(jobName); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "expboost");
return true; return true;
} }
@ -40,6 +37,7 @@ public class expboost implements Cmd {
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.EXP, 1.0); one.addBoost(CurrencyType.EXP, 1.0);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset")); sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
return true; return true;
} else if (args[0].equalsIgnoreCase("reset")) { } else if (args[0].equalsIgnoreCase("reset")) {
@ -59,7 +57,6 @@ public class expboost implements Cmd {
} }
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.EXP, rate); one.addBoost(CurrencyType.EXP, rate);
} }
@ -67,10 +64,7 @@ public class expboost implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
return true; return true;
} }
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.EXP, rate); job.addBoost(CurrencyType.EXP, rate);
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName())); sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true; return true;

View File

@ -28,19 +28,18 @@ public class moneyboost implements Cmd {
return true; return true;
} }
String PlayerName = sender.getName(); Job job = Jobs.getJob(args[0]);
String jobName = args[0]; if (job == null) {
Job job = Jobs.getJob(jobName); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true; return true;
} }
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.MONEY, 1.0); one.addBoost(CurrencyType.MONEY, 1.0);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset")); sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
return true; return true;
} else if (args[0].equalsIgnoreCase("reset")) { } else if (args[0].equalsIgnoreCase("reset")) {
@ -60,7 +59,6 @@ public class moneyboost implements Cmd {
} }
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.MONEY, rate); one.addBoost(CurrencyType.MONEY, rate);
} }
@ -68,10 +66,7 @@ public class moneyboost implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true; return true;
} }
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.MONEY, rate); job.addBoost(CurrencyType.MONEY, rate);
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName())); sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true; return true;

View File

@ -15,7 +15,6 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestObjective; import com.gamingmesh.jobs.container.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression; import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.CMILib.RawMessage; import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.stuff.TimeManage;
public class quests implements Cmd { public class quests implements Cmd {
@ -64,19 +63,8 @@ public class quests implements Cmd {
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]", String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded()); progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
List<String> hoverMsgs = Jobs.getLanguage().getMessageList("command.quests.output.hover");
List<String> hoverList = new ArrayList<>(); List<String> hoverList = new ArrayList<>();
hoverList.add(Jobs.getCommandManager().jobsQuestMessage(q, jobProg));
for (String current : hoverMsgs) {
current = current.replace("[jobName]", jobProg.getJob().getName());
current = current.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
if (current.contains("[desc]")) {
for (String one : q.getQuest().getDescription()) {
hoverList.add(one);
}
} else
hoverList.add(current);
}
for (Entry<String, QuestObjective> oneObjective : q.getQuest().getObjectives().entrySet()) { for (Entry<String, QuestObjective> oneObjective : q.getQuest().getObjectives().entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " + hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +

View File

@ -488,7 +488,7 @@ public class LanguageManager {
c.get("command.quests.toplineseparator", "&7*********************** &6[playerName] &2(&f[questsDone]&2) &7***********************"); c.get("command.quests.toplineseparator", "&7*********************** &6[playerName] &2(&f[questsDone]&2) &7***********************");
c.get("command.quests.output.completed", "&2 !Completed!&r "); c.get("command.quests.output.completed", "&2 !Completed!&r ");
c.get("command.quests.output.questLine", "[progress] &7[questName] &f[done]&7/&8[required]"); c.get("command.quests.output.questLine", "[progress] &7[questName] &f[done]&7/&8[required]");
c.get("command.quests.output.hover", Arrays.asList("&f[jobName]", "[desc]", "&7New quest in: [time]")); c.get("command.quests.output.hover", "&f[jobName] \n[desc] \n&7New quest in: [time]");
c.get("command.fire.help.info", "Fire the player from the job."); c.get("command.fire.help.info", "Fire the player from the job.");
c.get("command.fire.help.args", "[playername] [jobname]"); c.get("command.fire.help.args", "[playername] [jobname]");

View File

@ -29,13 +29,13 @@ public class Util {
public static List<String> confirmLeave = new ArrayList<>(); public static List<String> confirmLeave = new ArrayList<>();
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException { public static ItemStack setEntityType(ItemStack is, EntityType type) {
boolean useMeta; boolean useMeta;
try { try {
ItemStack testis = CMIMaterial.SPAWNER.newItemStack(); ItemStack testis = CMIMaterial.SPAWNER.newItemStack();
ItemMeta meta = testis.getItemMeta(); ItemMeta meta = testis.getItemMeta();
useMeta = meta instanceof BlockStateMeta; useMeta = meta instanceof BlockStateMeta;
} catch (Throwable e) { } catch (Exception e) {
useMeta = false; useMeta = false;
} }
@ -126,7 +126,7 @@ public class Util {
continue; continue;
if (lookingFor == null) { if (lookingFor == null) {
if (!CMIMaterial.AIR.equals(material) && !CMIMaterial.CAVE_AIR.equals(material) && !CMIMaterial.VOID_AIR.equals(material)) { if (!CMIMaterial.isAir(material)) {
break; break;
} }
} else { } else {