1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-03 22:12:17 +01:00

Add examples for how to use -all sub name

This commit is contained in:
montlikadani 2020-06-10 07:46:45 +02:00
parent 0a08dcf402
commit 3dbfe379aa
5 changed files with 63 additions and 45 deletions

View File

@ -1080,7 +1080,7 @@ public enum CMIMaterial {
@Deprecated
public Integer getLegacyId() {
return this.legacyId == null ? 0 : this.legacyId;
return legacyId == null ? 0 : legacyId;
}
@Deprecated
@ -1192,11 +1192,9 @@ public enum CMIMaterial {
}
public static CMIMaterial getRandom(CMIMaterial mat) {
List<CMIMaterial> ls = new ArrayList<CMIMaterial>();
List<CMIMaterial> ls = new ArrayList<>();
for (CMIMaterial one : CMIMaterial.values()) {
if (one.getLegacyId() == null)
continue;
if (!one.getLegacyId().equals(mat.getLegacyId()))
continue;
ls.add(one);
@ -1226,8 +1224,6 @@ public enum CMIMaterial {
if (mat == null)
return CMIMaterial.NONE;
for (CMIMaterial one : CMIMaterial.values()) {
if (one.getLegacyId() == null)
continue;
if (!one.getLegacyId().equals(mat.getLegacyId()))
continue;
if (one.getLegacyData() == id)
@ -1240,13 +1236,12 @@ public enum CMIMaterial {
public static CMIMaterial get(String id) {
if (id == null)
return CMIMaterial.NONE;
Integer ids;
Integer data;
id = id.replaceAll("_| |minecraft:", "").toLowerCase();
if (id.contains(":")) {
try {
ids = Integer.parseInt(id.split(":")[0]);
Integer ids = Integer.parseInt(id.split(":")[0]);
data = Integer.parseInt(id.split(":")[1]);
if (ids <= 0)
return CMIMaterial.NONE;
@ -2514,14 +2509,16 @@ public enum CMIMaterial {
if (newName.startsWith("STRIPPED")) {
return newName.replaceFirst("_[^_]+", "");
}
else if (newName.matches("^(DARK|LIGHT).+")) {
if (newName.matches("^(DARK|LIGHT).+")) {
return newName.replaceFirst(".+?_.+?_", "");
}
else if (newName.matches(
"^(WHITE|ORANGE|MAGENTA|YELLOW|LIME|PINK|GRAY|CYAN|PURPLE|BLUE|BROWN|GREEN|RED|BLACK|" +
if (newName.matches("^(WHITE|ORANGE|MAGENTA|YELLOW|LIME|PINK|GRAY|CYAN|PURPLE|BLUE|BROWN|GREEN|RED|BLACK|" +
"OAK|SPRUCE|BIRCH|JUNGLE|ACACIA).+")) {
return newName.replaceFirst(".+?_", "");
}
return fullName;
}
}

View File

@ -1402,10 +1402,12 @@ public class ConfigManager {
subType = myKey.split(":")[1];
}
}
if (type == null) {
log.warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
continue;
}
if (":ALL".equalsIgnoreCase(subType)) {
meta = "ALL";
type = CMIMaterial.getGeneralMaterialName(type);

View File

@ -51,6 +51,7 @@ public class NameTranslatorManager {
String fallbackMaterialName = Arrays.stream(materialName.split("\\s|:"))
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase())
.collect(Collectors.joining(" ")); // returns capitalized word (from this -> To This)
materialName = materialName.replace(" ", "");
CMIMaterial mat = CMIMaterial.get(materialName.replace(" ", ""));
@ -83,6 +84,7 @@ public class NameTranslatorManager {
if (nameLs != null && nameMeta != null) {
return nameLs + ":" + nameMeta;
}
if (mat.equals(CMIMaterial.NONE)) {
return fallbackMaterialName;
}

View File

@ -18,9 +18,8 @@
package com.gamingmesh.jobs.container;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.PotionItemActionInfo;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
@ -226,10 +225,11 @@ public class Job {
}
public JobInfo getJobInfo(ActionInfo action, int level) {
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) ->
jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
jobInfo.getName().equalsIgnoreCase(action.getName());
};
String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName());
for (JobInfo info : getJobInfo(action.getType())) {
@ -237,12 +237,15 @@ public class Job {
if (!info.isInLevelRange(level)) {
break;
}
return info;
}
if ((shortActionName + ":ALL").equalsIgnoreCase(info.getName())) {
return info;
}
}
return null;
}

View File

@ -226,6 +226,20 @@ Jobs:
# you can use minuses to take away money if the player break this block
income: -1.0
experience: -1.0
# you can use here "-all" sub name to specify if we detect all wool colours
wool-all:
income: 2.0
points: 1.0
experience: 1.0
log-all:
income: 1.0
points: 1.0
experience: 1.0
# you should start material name like this, to detect if that material is exists
white_banner-all:
income: 1.0
points: 1.0
experience: 1.0
# Payment for collecting things like sweet berry bush, composter or honey
Collect:
sweet_berry_bush-3: