mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Check job info meta before the material name for better match
This commit is contained in:
parent
182039647c
commit
03effd2e13
@ -122,8 +122,13 @@ public class JobsCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (page < 1) {
|
||||
ActionBarManager.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PageInfo pi = new PageInfo(7, commands.size(), page);
|
||||
if (page > pi.getTotalPages() || page < 1) {
|
||||
if (page > pi.getTotalPages()) {
|
||||
ActionBarManager.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
return true;
|
||||
}
|
||||
|
@ -78,10 +78,11 @@ public class browse implements Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
if (one.getMaxLevel(sender) > 0) {
|
||||
int maxLevel = one.getMaxLevel(sender);
|
||||
if (maxLevel > 0) {
|
||||
if (!hoverMsg.isEmpty())
|
||||
hoverMsg += " \n";
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", one.getMaxLevel(sender));
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel);
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().ShowTotalWorkers) {
|
||||
@ -94,10 +95,12 @@ public class browse implements Cmd {
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
if (!hoverMsg.isEmpty())
|
||||
hoverMsg += " \n";
|
||||
if ((int) (one.getBonus() * 100) < 0)
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (one.getBonus() * 100) * -1);
|
||||
|
||||
int bonus = (int) (one.getBonus() * 100);
|
||||
if (bonus < 0)
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1);
|
||||
else
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (one.getBonus() * 100));
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus);
|
||||
}
|
||||
|
||||
if (!hoverMsg.isEmpty())
|
||||
@ -122,10 +125,11 @@ public class browse implements Cmd {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
if ((int) (j.getBonus() * 100) < 0)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1));
|
||||
int bonus = (int) (j.getBonus() * 100);
|
||||
if (bonus < 0)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
|
||||
else
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
|
||||
}
|
||||
|
||||
for (String one : j.getFullDescription()) {
|
||||
@ -163,10 +167,11 @@ public class browse implements Cmd {
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.totalWorkers", "[amount]", one.getTotalPlayers());
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
if ((int) (one.getBonus() * 100) < 0)
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.penalty", "[amount]", (int) (one.getBonus() * 100) * -1);
|
||||
int bonus = (int) (one.getBonus() * 100);
|
||||
if (bonus < 0)
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.penalty", "[amount]", bonus * -1);
|
||||
else
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.bonus", "[amount]", (int) (one.getBonus() * 100));
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.bonus", "[amount]", bonus);
|
||||
}
|
||||
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName());
|
||||
@ -184,10 +189,11 @@ public class browse implements Cmd {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
if ((int) (j.getBonus() * 100) < 0)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1));
|
||||
int bonus = (int) (j.getBonus() * 100);
|
||||
if (bonus < 0)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
|
||||
else
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
|
||||
}
|
||||
|
||||
for (String one : j.getFullDescription()) {
|
||||
@ -218,11 +224,13 @@ public class browse implements Cmd {
|
||||
if (Jobs.getGCManager().ShowTotalWorkers)
|
||||
builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
|
||||
if (job.getBonus() < 0)
|
||||
builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
int bonus = (int) (job.getBonus() * 100);
|
||||
if (bonus < 0)
|
||||
builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1));
|
||||
else
|
||||
builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
|
||||
builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus));
|
||||
}
|
||||
|
||||
lines.add(builder.toString());
|
||||
|
||||
|
@ -558,20 +558,19 @@ public class ConfigManager {
|
||||
|
||||
final String finalMyKey = myKey;
|
||||
|
||||
if (myKey.contains("-")) {
|
||||
String[] split = myKey.split("-", 2);
|
||||
String[] keySplit = myKey.split("-", 2);
|
||||
|
||||
if (split.length > 1) {
|
||||
subType = ":" + split[1];
|
||||
meta = split[1];
|
||||
if (keySplit.length > 0) {
|
||||
if (keySplit.length > 1) {
|
||||
subType = ":" + keySplit[1];
|
||||
meta = keySplit[1];
|
||||
}
|
||||
|
||||
myKey = split[0];
|
||||
} else if (myKey.contains(":")) { // when we uses tipped arrow effect types
|
||||
String[] split = myKey.split(":", 2);
|
||||
meta = split.length > 1 ? split[1] : myKey;
|
||||
myKey = keySplit[0];
|
||||
} else if ((keySplit = myKey.split(":", 2)).length > 0) { // when we uses tipped arrow effect types
|
||||
meta = keySplit.length > 1 ? keySplit[1] : myKey;
|
||||
subType = ":all";
|
||||
myKey = split[0];
|
||||
myKey = keySplit[0];
|
||||
}
|
||||
|
||||
String type = null;
|
||||
@ -616,12 +615,10 @@ public class ConfigManager {
|
||||
matId = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
if (matId != null) {
|
||||
material = CMIMaterial.get(matId);
|
||||
if (material != CMIMaterial.NONE) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
||||
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
|
||||
if (matId != null && (material = CMIMaterial.get(matId)) != CMIMaterial.NONE) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
||||
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -697,8 +694,14 @@ public class ConfigManager {
|
||||
// END HACK
|
||||
|
||||
type = material.getMaterial().toString();
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_12_R1) && material.getLegacyData() > 0)
|
||||
subType = ":" + material.getLegacyData();
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_12_R1)) {
|
||||
short legacyData = material.getLegacyData();
|
||||
|
||||
if (legacyData > 0)
|
||||
subType = ":" + legacyData;
|
||||
}
|
||||
|
||||
id = material.getId();
|
||||
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
|
||||
// check entities
|
||||
@ -789,8 +792,9 @@ public class ConfigManager {
|
||||
type = myKey.substring(1, myKey.length());
|
||||
}
|
||||
|
||||
if (myKey.contains(":")) {
|
||||
subType = myKey.split(":", 2)[1];
|
||||
String[] split = myKey.split(":", 2);
|
||||
if (split.length > 1) {
|
||||
subType = split[1];
|
||||
}
|
||||
} else if (actionType == ActionType.SHEAR && !myKey.startsWith("color")) {
|
||||
type = myKey;
|
||||
@ -1112,16 +1116,14 @@ public class ConfigManager {
|
||||
matId = Integer.valueOf(item);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
if (matId != null) {
|
||||
material = CMIMaterial.get(matId);
|
||||
if (material != null) {
|
||||
log.warning("Job " + jobFullName + " is using GUI item ID: " + item + "!");
|
||||
log.warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
|
||||
if (matId != null && (material = CMIMaterial.get(matId)) != CMIMaterial.NONE) {
|
||||
log.warning("Job " + jobFullName + " is using GUI item ID: " + item + "!");
|
||||
log.warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
}
|
||||
|
||||
if (material != null)
|
||||
if (material != CMIMaterial.NONE)
|
||||
guiItem = material.newItemStack();
|
||||
} else if (guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
||||
guiItem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
@ -1186,18 +1188,20 @@ public class ConfigManager {
|
||||
if (conditionsSection != null) {
|
||||
for (String conditionKey : conditionsSection.getKeys(false)) {
|
||||
ConfigurationSection permissionSection = conditionsSection.getConfigurationSection(conditionKey);
|
||||
|
||||
if (permissionSection == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid condition key " + conditionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!permissionSection.contains("requires") || !permissionSection.contains("perform")) {
|
||||
List<String> requires = permissionSection.getStringList("requires");
|
||||
List<String> perform = permissionSection.getStringList("perform");
|
||||
|
||||
if (requires.isEmpty() || perform.isEmpty()) {
|
||||
log.warning("Job " + jobKey + " has an invalid condition requirement " + conditionKey + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> requires = permissionSection.getStringList("requires"),
|
||||
perform = permissionSection.getStringList("perform");
|
||||
jobConditions.add(new JobConditions(conditionKey.toLowerCase(), requires, perform));
|
||||
}
|
||||
}
|
||||
@ -1295,7 +1299,7 @@ public class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
CMIMaterial mat = null;
|
||||
CMIMaterial mat = CMIMaterial.NONE;
|
||||
|
||||
if (itemSection.isInt("id")) {
|
||||
mat = CMIMaterial.get(itemSection.getInt("id"));
|
||||
@ -1303,7 +1307,7 @@ public class ConfigManager {
|
||||
mat = CMIMaterial.get(itemSection.getString("id"));
|
||||
}
|
||||
|
||||
if (mat == null) {
|
||||
if (mat == CMIMaterial.NONE) {
|
||||
log.warning("Job " + jobKey + " has incorrect limitedItems material id!");
|
||||
continue;
|
||||
}
|
||||
@ -1454,8 +1458,8 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + quests.size() + " quests for " + jobFullName);
|
||||
job.setQuests(quests);
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + quests.size() + " quests for " + jobFullName);
|
||||
}
|
||||
job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1));
|
||||
|
||||
|
@ -48,29 +48,9 @@ public class NameTranslatorManager {
|
||||
case STRIPLOGS:
|
||||
materialName = materialName.replace(" ", "");
|
||||
|
||||
CMIMaterial mat = CMIMaterial.get(materialName);
|
||||
NameList nameLs = listOfNames.get(mat);
|
||||
|
||||
if (nameLs != null) {
|
||||
if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) {
|
||||
return nameLs.getName() + ":" + meta;
|
||||
}
|
||||
|
||||
return nameLs.getName();
|
||||
}
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
mat = CMIMaterial.get(materialName);
|
||||
nameLs = listOfNames.get(mat);
|
||||
|
||||
if (nameLs != null) {
|
||||
return nameLs.getName();
|
||||
}
|
||||
}
|
||||
|
||||
if (meta != null && !meta.isEmpty()) {
|
||||
mat = CMIMaterial.get(materialName + ":" + meta);
|
||||
nameLs = listOfNames.get(mat);
|
||||
CMIMaterial mat = CMIMaterial.get(materialName + ":" + meta);
|
||||
NameList nameLs = listOfNames.get(mat);
|
||||
|
||||
if (nameLs == null) {
|
||||
mat = CMIMaterial.get(materialName.replace(" ", ""));
|
||||
@ -93,6 +73,19 @@ public class NameTranslatorManager {
|
||||
}
|
||||
}
|
||||
|
||||
CMIMaterial mat = CMIMaterial.get(materialName);
|
||||
NameList nameLs = listOfNames.get(mat);
|
||||
|
||||
if (nameLs != null) {
|
||||
if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) {
|
||||
return nameLs.getName() + ":" + meta;
|
||||
}
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
return nameLs.getName();
|
||||
}
|
||||
}
|
||||
|
||||
if (id > 0 && meta != null && !meta.isEmpty()) {
|
||||
mat = CMIMaterial.get(id + ":" + meta);
|
||||
nameLs = listOfNames.get(mat);
|
||||
|
@ -34,15 +34,16 @@ public class RestrictedBlockManager {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) {
|
||||
CMIItemStack cm = ItemManager.getItem(CMIMaterial.get(section.getString(one + ".id")));
|
||||
CMIMaterial mat = cm == null ? null : cm.getCMIType();
|
||||
|
||||
if (cm == null || !cm.getCMIType().isBlock()) {
|
||||
if (mat == null || !mat.isBlock()) {
|
||||
Jobs.consoleMsg("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!");
|
||||
continue;
|
||||
}
|
||||
|
||||
int cd = section.getInt(one + ".cd");
|
||||
restrictedBlocksTimer.put(cm.getCMIType(), cd);
|
||||
cfg.set("blocksTimer." + cm.getCMIType().name(), cd);
|
||||
restrictedBlocksTimer.put(mat, cd);
|
||||
cfg.set("blocksTimer." + mat.name(), cd);
|
||||
} else {
|
||||
CMIMaterial mat = CMIMaterial.get(one);
|
||||
if (mat == CMIMaterial.NONE)
|
||||
|
@ -80,20 +80,21 @@ public class JobItems {
|
||||
setJobs(jobs);
|
||||
|
||||
ItemMeta meta = (item = mat.newItemStack()).getItemMeta();
|
||||
if (potion != null && CMIMaterial.isPotion(mat.getMaterial()) && meta instanceof PotionMeta) {
|
||||
if (potion != null && meta instanceof PotionMeta && CMIMaterial.isPotion(mat.getMaterial())) {
|
||||
PotionMeta potionMeta = (PotionMeta) meta;
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1) && potion instanceof org.bukkit.potion.PotionData) {
|
||||
potionMeta.setBasePotionData((org.bukkit.potion.PotionData) potion);
|
||||
} else if (potion instanceof org.bukkit.potion.Potion) {
|
||||
PotionEffectType effectType = ((org.bukkit.potion.Potion) potion).getType().getEffectType();
|
||||
|
||||
if (effectType != null) {
|
||||
potionMeta.setMainEffect(effectType);
|
||||
}
|
||||
}
|
||||
|
||||
meta = potionMeta;
|
||||
} else if (leatherColor != null && CMIMaterial.isLeatherArmor(mat.getMaterial()) && meta instanceof LeatherArmorMeta) {
|
||||
} else if (leatherColor != null && meta instanceof LeatherArmorMeta && CMIMaterial.isLeatherArmor(mat.getMaterial())) {
|
||||
LeatherArmorMeta armorMeta = (LeatherArmorMeta) meta;
|
||||
armorMeta.setColor(this.leatherColor = leatherColor);
|
||||
meta = armorMeta;
|
||||
@ -140,13 +141,14 @@ public class JobItems {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (CMIMaterial.isPotion(item.getType()) && potion != null && meta instanceof PotionMeta) {
|
||||
if (potion != null && CMIMaterial.isPotion(item.getType()) && meta instanceof PotionMeta) {
|
||||
PotionMeta potionMeta = (PotionMeta) meta;
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1) && potion instanceof org.bukkit.potion.PotionData) {
|
||||
potionMeta.setBasePotionData((org.bukkit.potion.PotionData) potion);
|
||||
} else if (potion instanceof org.bukkit.potion.Potion) {
|
||||
PotionEffectType effectType = ((org.bukkit.potion.Potion) potion).getType().getEffectType();
|
||||
|
||||
if (effectType != null) {
|
||||
potionMeta.setMainEffect(effectType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user