1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Added "color-all" identifier for shear action (#970)

Closes #966
This commit is contained in:
kikelkik 2020-10-21 17:28:19 +02:00 committed by GitHub
parent 58bcb0d45a
commit 081b02c7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 16 deletions

View File

@ -2624,6 +2624,11 @@ public enum CMIMaterial {
return newName.replaceFirst(".+?_", "");
}
if (newName.matches("(?i)^(WHITE|ORANGE|MAGENTA|YELLOW|LIME|PINK|GRAY|CYAN|PURPLE|BLUE|BROWN|GREEN|RED|BLACK|" +
"LIGHT_GRAY|LIGHT_BLUE|)$")) {
return "color";
}
return fullName;
}

View File

@ -389,12 +389,12 @@ public class ConfigManager {
meta = "";
int id = 0;
if (myKey.contains("-")) {
if (myKey.contains("-") && !myKey.endsWith("-all")) {
// uses subType
subType = ":" + myKey.split("-")[1];
meta = myKey.split("-")[1];
myKey = myKey.split("-")[0];
} else if (myKey.contains(":")) { // when we uses tipped arrow effect types
} else if (myKey.contains(":") && !myKey.endsWith(":all")) { // when we uses tipped arrow effect types
String[] split = myKey.split(":");
meta = split.length > 1 ? split[1] : myKey;
myKey = split[0];
@ -592,7 +592,7 @@ public class ConfigManager {
type = enchant == null ? myKey : enchant.toString();
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.COLLECT || actionType == ActionType.MMKILL
|| actionType == ActionType.SHEAR || actionType == ActionType.BAKE || actionType == ActionType.BOSS) {
|| actionType == ActionType.BAKE || actionType == ActionType.BOSS) {
type = myKey;
} else if (actionType == ActionType.EXPLORE) {
type = myKey;
@ -615,6 +615,13 @@ public class ConfigManager {
if (myKey.contains(":")) {
subType = myKey.split(":")[1];
}
} else if (actionType == ActionType.SHEAR) {
if (myKey.startsWith("color") && (myKey.endsWith("-all") || myKey.endsWith(":all"))) {
subType = ":all";
type = myKey.split(":|-")[0];
} else {
type = myKey;
}
}
if (type == null) {
@ -624,7 +631,8 @@ public class ConfigManager {
if (":ALL".equalsIgnoreCase(subType)) {
meta = "ALL";
type = CMIMaterial.getGeneralMaterialName(type);
// case for ":all" identifier
type = (actionType == ActionType.SHEAR && myKey.startsWith("color")) ? "color" : CMIMaterial.getGeneralMaterialName(type);
}
if (actionType == ActionType.TNTBREAK)

View File

@ -29,7 +29,7 @@ public class NameTranslatorManager {
return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
}
public String Translate(String materialName, ActionType action, Integer id, String meta, String mame) {
public String Translate(String materialName, ActionType action, Integer id, String meta, String name) {
// Translating name to user friendly
if (Jobs.getGCManager().UseCustomNames)
switch (action) {
@ -63,7 +63,7 @@ public class NameTranslatorManager {
return nameLs.getName();
}
if (mame != null && !mame.isEmpty()) {
if (name != null && !name.isEmpty()) {
mat = CMIMaterial.get(materialName.replace(" ", ""));
nameLs = ListOfNames.get(mat);
@ -114,34 +114,35 @@ public class NameTranslatorManager {
return one.getName();
}
ids = one.getMinecraftName();
if (ids.equalsIgnoreCase(mame)) {
if (ids.equalsIgnoreCase(name)) {
return one.getName();
}
}
break;
case ENCHANT:
String name = materialName;
String mName = materialName;
String level = "";
if (name.contains(":")) {
name = materialName.split(":")[0];
if (mName.contains(":")) {
mName = materialName.split(":")[0];
level = ":" + materialName.split(":")[1];
}
NameList nameInfo = ListOfEnchants.get(name.toLowerCase().replace("_", ""));
NameList nameInfo = ListOfEnchants.get(mName.toLowerCase().replace("_", ""));
if (nameInfo != null) {
return nameInfo.getMinecraftName() + level;
}
return materialName;
case CUSTOMKILL:
case EXPLORE:
break;
case SHEAR:
for (NameList one : ListOfColors) {
String ids = one.getMinecraftName();
if (ids.equalsIgnoreCase(mame)) {
if (ids.equalsIgnoreCase(name)) {
return one.getName();
}
}
break;
String fallbackColorName = Arrays.stream(name.split("\\s|:|-"))
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase())
.collect(Collectors.joining(" ")); // returns capitalized word (from this -> To This)
return fallbackColorName;
case MMKILL:
NameList got = ListOfMMEntities.get(materialName.toLowerCase());
if (got != null && got.getName() != null)

View File

@ -350,6 +350,7 @@ Jobs:
income: 5.0
experience: 10.0
# Shear sheeps by its color
# You can use "color-all" to specify all known colors.
Shear:
Black:
income: 2.0