mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-18 05:11:32 +01:00
Correct command sorting order
This commit is contained in:
parent
283525e853
commit
0df98f0246
@ -33,6 +33,7 @@ public class CMIChatColor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (float x = 0.0F; x <= 1; x += 0.1) {
|
||||
for (float z = 0.1F; z <= 1; z += 0.1) {
|
||||
for (float y = 0; y <= 1; y += 0.03) {
|
||||
@ -49,9 +50,56 @@ public class CMIChatColor {
|
||||
|
||||
public final static String colorReplacerPlaceholder = "\uFF06";
|
||||
|
||||
public static final String colorFontPrefix = "{@";
|
||||
public static final String colorCodePrefix = "{#";
|
||||
public static final String colorCodeSuffix = "}";
|
||||
|
||||
private static String charEscape(String s) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
|
||||
switch (ch) {
|
||||
case '"':
|
||||
sb.append("\\\"");
|
||||
break;
|
||||
case '\n':
|
||||
sb.append("\\n");
|
||||
break;
|
||||
case '\\':
|
||||
sb.append("\\\\");
|
||||
break;
|
||||
case '\b':
|
||||
sb.append("\\b");
|
||||
break;
|
||||
case '\f':
|
||||
sb.append("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
sb.append("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
sb.append("\\t");
|
||||
break;
|
||||
case '/':
|
||||
sb.append("/");
|
||||
break;
|
||||
default:
|
||||
if ((ch >= '\u0000' && ch <= '\u001F') || (ch >= '\u007F' && ch <= '\u009F') || (ch >= '\u2000' && ch <= '\u20FF')) {
|
||||
String ss = Integer.toHexString(ch);
|
||||
sb.append("\\u");
|
||||
for (int k = 0; k < 4 - ss.length(); k++) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(ss.toUpperCase());
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String escape(String text) {
|
||||
return text.replace("#", "\\#").replace("{", "\\{").replace("}", "\\}");
|
||||
}
|
||||
@ -64,13 +112,16 @@ public class CMIChatColor {
|
||||
public static final Pattern hexColorNamePattern = Pattern.compile(CMIChatColor.ColorNameRegex);
|
||||
public static final Pattern hexColorNamePatternLast = Pattern.compile(ColorNameRegex + "(?!.*\\{#)");
|
||||
|
||||
public static final String ColorFontRegex = "(\\" + colorFontPrefix + ")([a-zA-Z_]{3,})(\\" + colorCodeSuffix + ")";
|
||||
|
||||
public static final Pattern gradientPattern = Pattern.compile("(\\{(#[^\\{]*?)>\\})(.*?)(\\{(#.*?)<(>?)\\})");
|
||||
|
||||
public static final String hexColorDecolRegex = "(&x)(&[0-9A-Fa-f]){6}";
|
||||
|
||||
public static final Pattern postGradientPattern = Pattern.compile("(" + CMIChatColor.hexColorRegex + "|" + CMIChatColor.ColorNameRegex + ")" + "(.)" + "(" + CMIChatColor.hexColorRegex + "|"
|
||||
+ CMIChatColor.ColorNameRegex + ")");
|
||||
public static final Pattern fullPattern = Pattern.compile("(&[0123456789abcdefklmnorABCDEFKLMNOR])|" + CMIChatColor.hexColorRegex + "|" + CMIChatColor.ColorNameRegex);
|
||||
public static final Pattern fullPattern = Pattern.compile("(&[0123456789abcdefklmnorABCDEFKLMNOR])|" + CMIChatColor.hexColorRegex + "|" + CMIChatColor.ColorNameRegex + "|"
|
||||
+ CMIChatColor.ColorFontRegex);
|
||||
|
||||
public static final CMIChatColor BLACK = new CMIChatColor("Black", '0', 0, 0, 0);
|
||||
public static final CMIChatColor DARK_BLUE = new CMIChatColor("Dark_Blue", '1', 0, 0, 170);
|
||||
@ -181,10 +232,15 @@ public class CMIChatColor {
|
||||
|
||||
double percent = (i * 100D) / (length - 1);
|
||||
|
||||
// if (gtext.length() == 1) {
|
||||
// percent = 50D;
|
||||
// }
|
||||
|
||||
CMIChatColor mix = CMIChatColor.mixColors(c1, c2, percent);
|
||||
updated += CMIChatColor.colorCodePrefix + mix.getHex() + CMIChatColor.colorCodeSuffix;
|
||||
|
||||
updated += String.valueOf(ch);
|
||||
// updated += charEscape(String.valueOf(ch));
|
||||
}
|
||||
|
||||
if (continuous) {
|
||||
@ -502,7 +558,7 @@ public class CMIChatColor {
|
||||
}
|
||||
|
||||
public static CMIChatColor getRandomColor() {
|
||||
List<CMIChatColor> ls = new ArrayList<>();
|
||||
List<CMIChatColor> ls = new ArrayList<CMIChatColor>();
|
||||
for (Entry<String, CMIChatColor> one : BY_NAME.entrySet()) {
|
||||
if (!one.getValue().isColor())
|
||||
continue;
|
||||
@ -544,7 +600,7 @@ public class CMIChatColor {
|
||||
|
||||
public static CMIChatColor getByCustomName(String name) {
|
||||
if (name.equalsIgnoreCase("random")) {
|
||||
List<CMIChatColor> valuesList = new ArrayList<>(CUSTOM_BY_NAME.values());
|
||||
List<CMIChatColor> valuesList = new ArrayList<CMIChatColor>(CUSTOM_BY_NAME.values());
|
||||
int randomIndex = new Random().nextInt(valuesList.size());
|
||||
return valuesList.get(randomIndex);
|
||||
}
|
||||
|
@ -246,15 +246,15 @@ public enum CMIEntityType {
|
||||
"OTlkYzNmMDBlY2FiMjI0OWJiNmExNmM4YzUxMTVjZWI5ZjIzMjA1YTBkNTVjYzBlOWJhYmQyNTYyZjc5NTljNCJ9fX0==",
|
||||
"ZTZiNzRlMDUyYjc0Mjg4Nzk5YmE2ZDlmMzVjNWQwMjIxY2Y4YjA0MzMxNTQ3ZWMyZjY4ZDczNTk3YWUyYzliIn19fQ==",
|
||||
"YmIxNzc3NDY2MjUxMmQ3ODdlZjc3YjFhNDZhMDRlMmM2ZmQ2Nzc5NGJmN2Y3Nzk1NjZlYjIxYzgxNDNhYWQ5ZSJ9fX0=")),
|
||||
|
||||
ZOMBIFIED_PIGLIN(929, "Zombified Piglin", Arrays.asList("N2VhYmFlY2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0=")),
|
||||
HOGLIN(925, "Hoglin", Arrays.asList("OWJiOWJjMGYwMWRiZDc2MmEwOGQ5ZTc3YzA4MDY5ZWQ3Yzk1MzY0YWEzMGNhMTA3MjIwODU2MWI3MzBlOGQ3NSJ9fX0=")),
|
||||
PIGLIN(926, "Piglin", Arrays.asList("OWYxODEwN2QyNzVmMWNiM2E5Zjk3M2U1OTI4ZDU4NzlmYTQwMzI4ZmYzMjU4MDU0ZGI2ZGQzZTdjMGNhNjMzMCJ9fX0=")),
|
||||
STRIDER(927, "Strider", Arrays.asList("MThhOWFkZjc4MGVjN2RkNDYyNWM5YzA3NzkwNTJlNmExNWE0NTE4NjY2MjM1MTFlNGM4MmU5NjU1NzE0YjNjMSJ9fX0=")),
|
||||
ZOGLIN(928, "Zoglin", Arrays.asList("ZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0=")),
|
||||
|
||||
|
||||
ZOMBIFIED_PIGLIN(925, "Zombified Piglin", Arrays.asList("N2VhYmFlY2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0=")),
|
||||
HOGLIN(926, "Hoglin", Arrays.asList("OWJiOWJjMGYwMWRiZDc2MmEwOGQ5ZTc3YzA4MDY5ZWQ3Yzk1MzY0YWEzMGNhMTA3MjIwODU2MWI3MzBlOGQ3NSJ9fX0=")),
|
||||
PIGLIN(927, "Piglin", Arrays.asList("OWYxODEwN2QyNzVmMWNiM2E5Zjk3M2U1OTI4ZDU4NzlmYTQwMzI4ZmYzMjU4MDU0ZGI2ZGQzZTdjMGNhNjMzMCJ9fX0=")),
|
||||
STRIDER(928, "Strider", Arrays.asList("MThhOWFkZjc4MGVjN2RkNDYyNWM5YzA3NzkwNTJlNmExNWE0NTE4NjY2MjM1MTFlNGM4MmU5NjU1NzE0YjNjMSJ9fX0=")),
|
||||
ZOGLIN(929, "Zoglin", Arrays.asList("ZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0=")),
|
||||
|
||||
// 1.16.2
|
||||
PIGLIN_BRUTE(929, "Piglin Brute", Arrays.asList("M2UzMDBlOTAyNzM0OWM0OTA3NDk3NDM4YmFjMjllM2E0Yzg3YTg0OGM1MGIzNGMyMTI0MjcyN2I1N2Y0ZTFjZiJ9fX0=")),
|
||||
PIGLIN_BRUTE(930, "Piglin Brute", Arrays.asList("M2UzMDBlOTAyNzM0OWM0OTA3NDk3NDM4YmFjMjllM2E0Yzg3YTg0OGM1MGIzNGMyMTI0MjcyN2I1N2Y0ZTFjZiJ9fX0=")),
|
||||
|
||||
// if possible we can remove this string for each texture to save up some space
|
||||
// eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUv
|
||||
|
@ -11,10 +11,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class RawMessage {
|
||||
|
||||
List<String> parts = new ArrayList<>();
|
||||
List<String> onlyText = new ArrayList<>();
|
||||
List<String> parts = new ArrayList<String>();
|
||||
List<String> onlyText = new ArrayList<String>();
|
||||
|
||||
LinkedHashMap<RawMessagePartType, String> temp = new LinkedHashMap<>();
|
||||
LinkedHashMap<RawMessagePartType, String> temp = new LinkedHashMap<RawMessagePartType, String>();
|
||||
|
||||
RawMessageFragment fragment = new RawMessageFragment();
|
||||
RawMessageFragment hoverFragment = new RawMessageFragment();
|
||||
@ -28,8 +28,8 @@ public class RawMessage {
|
||||
private boolean dontBreakLine = false;
|
||||
|
||||
public void clear() {
|
||||
parts = new ArrayList<>();
|
||||
onlyText = new ArrayList<>();
|
||||
parts = new ArrayList<String>();
|
||||
onlyText = new ArrayList<String>();
|
||||
combined = "";
|
||||
combinedClean = "";
|
||||
}
|
||||
@ -46,7 +46,7 @@ public class RawMessage {
|
||||
Matcher match = CMIChatColor.fullPattern.matcher(text);
|
||||
String matcher = null;
|
||||
|
||||
List<RawMessageFragment> fragments = new ArrayList<>();
|
||||
List<RawMessageFragment> fragments = new ArrayList<RawMessageFragment>();
|
||||
|
||||
RawMessageFragment f = hover ? hoverFragment : fragment;
|
||||
|
||||
@ -72,6 +72,12 @@ public class RawMessage {
|
||||
fragments.add(f);
|
||||
f = new RawMessageFragment(f);
|
||||
}
|
||||
|
||||
if (matcher.startsWith(CMIChatColor.colorFontPrefix)) {
|
||||
f.setFont(matcher);
|
||||
continue;
|
||||
}
|
||||
|
||||
CMIChatColor color = CMIChatColor.getColor(matcher);
|
||||
if (color == null)
|
||||
continue;
|
||||
@ -124,6 +130,11 @@ public class RawMessage {
|
||||
finalText.append(",");
|
||||
}
|
||||
|
||||
if (one.getFont() != null) {
|
||||
finalText.append("\"font\":\"" + one.getFont() + "\",");
|
||||
|
||||
}
|
||||
|
||||
if (one.getLastColor() != null) {
|
||||
if (one.getLastColor().getHex() != null)
|
||||
finalText.append("\"color\":\"#" + one.getLastColor().getHex() + "\",");
|
||||
@ -160,6 +171,7 @@ public class RawMessage {
|
||||
|
||||
if (finalText.toString().isEmpty())
|
||||
return "";
|
||||
// CMIDebug.d(finalText);
|
||||
return "{" + finalText.toString() + "}";
|
||||
}
|
||||
|
||||
@ -444,7 +456,7 @@ public class RawMessage {
|
||||
}
|
||||
|
||||
public List<String> softCombine() {
|
||||
List<String> ls = new ArrayList<>();
|
||||
List<String> ls = new ArrayList<String>();
|
||||
String f = "";
|
||||
for (String part : parts) {
|
||||
if (f.isEmpty())
|
||||
|
@ -1,55 +1,67 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class RawMessageFragment {
|
||||
|
||||
private CMIChatColor lastColor = null;
|
||||
private Set<CMIChatColor> formats = new HashSet<>();
|
||||
String font = null;
|
||||
private String text = "";
|
||||
|
||||
public RawMessageFragment() {
|
||||
}
|
||||
|
||||
public RawMessageFragment(RawMessageFragment old) {
|
||||
this.lastColor = old.lastColor;
|
||||
this.formats = new HashSet<>(old.formats);
|
||||
this.font = old.font;
|
||||
}
|
||||
|
||||
public CMIChatColor getLastColor() {
|
||||
return lastColor;
|
||||
}
|
||||
|
||||
public void setLastColor(CMIChatColor lastColor) {
|
||||
this.lastColor = lastColor;
|
||||
formats.clear();
|
||||
}
|
||||
|
||||
public Set<CMIChatColor> getFormats() {
|
||||
return formats;
|
||||
}
|
||||
|
||||
public void setFormats(Set<CMIChatColor> formats) {
|
||||
this.formats = formats;
|
||||
}
|
||||
|
||||
public void addFormat(CMIChatColor format) {
|
||||
if (format.isReset()) {
|
||||
this.formats.clear();
|
||||
this.lastColor = null;
|
||||
return;
|
||||
}
|
||||
this.formats.add(format);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class RawMessageFragment {
|
||||
|
||||
private CMIChatColor lastColor = null;
|
||||
private Set<CMIChatColor> formats = new HashSet<CMIChatColor>();
|
||||
private String font = null;
|
||||
private String text = "";
|
||||
|
||||
public RawMessageFragment() {
|
||||
}
|
||||
|
||||
public RawMessageFragment(RawMessageFragment old) {
|
||||
this.lastColor = old.lastColor;
|
||||
this.formats = new HashSet<CMIChatColor>(old.formats);
|
||||
this.font = old.font;
|
||||
}
|
||||
|
||||
public CMIChatColor getLastColor() {
|
||||
return lastColor;
|
||||
}
|
||||
|
||||
public void setLastColor(CMIChatColor lastColor) {
|
||||
this.lastColor = lastColor;
|
||||
formats.clear();
|
||||
}
|
||||
|
||||
public Set<CMIChatColor> getFormats() {
|
||||
return formats;
|
||||
}
|
||||
|
||||
public void setFormats(Set<CMIChatColor> formats) {
|
||||
this.formats = formats;
|
||||
}
|
||||
|
||||
public void addFormat(CMIChatColor format) {
|
||||
if (format.isReset()) {
|
||||
this.formats.clear();
|
||||
this.lastColor = null;
|
||||
return;
|
||||
}
|
||||
this.formats.add(format);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
public void setFont(String font) {
|
||||
if (font.startsWith(CMIChatColor.colorFontPrefix) && font.length() > CMIChatColor.colorFontPrefix.length())
|
||||
font = font.substring(CMIChatColor.colorFontPrefix.length());
|
||||
if (font.endsWith(CMIChatColor.colorCodeSuffix) && font.length() > CMIChatColor.colorCodeSuffix.length())
|
||||
font = font.substring(0, font.length() - CMIChatColor.colorCodeSuffix.length());
|
||||
this.font = font;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
public enum RawMessagePartType {
|
||||
Text, HoverText, HoverItem, HoverEntity, HoverAchievement, ClickLink, ClickCommand, ClickSuggestion, ClickInsertion;
|
||||
}
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
public enum RawMessagePartType {
|
||||
Text, HoverText, HoverItem, HoverEntity, HoverAchievement, ClickLink, ClickCommand, ClickSuggestion, ClickInsertion;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
commands = Sorting.sortDESC(commands);
|
||||
commands = Sorting.sortASC(commands);
|
||||
|
||||
PageInfo pi = new PageInfo(7, commands.size(), page);
|
||||
if (page > pi.getTotalPages() || page < 1) {
|
||||
@ -198,6 +198,8 @@ public class JobsCommands implements CommandExecutor {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static Class<?> getClass(String cmd) {
|
||||
|
Loading…
Reference in New Issue
Block a user