1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-29 04:18:07 +01:00

Using internal unicode parser to avoid having dependency on specific

library
This commit is contained in:
Zrips 2023-09-20 11:23:45 +03:00
parent 8487156399
commit 46a244417b
4 changed files with 63 additions and 17 deletions

16
pom.xml
View File

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId>
<artifactId>jobs</artifactId>
<version>5.2.1.0</version>
<version>5.2.1.1</version>
<name>Jobs</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -199,8 +201,7 @@
<scope>system</scope>
<systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath>
</dependency>
<!-- WildStacker -->
<!-- WildStacker -->
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>WildStackerAPI</artifactId>
@ -222,7 +223,7 @@
<artifactId>mypet</artifactId>
<version>3.11-SNAPSHOT</version>
<scope>system</scope>
<!-- Temporary solution for replacing repository -->
<!-- Temporary solution for replacing repository -->
<systemPath>${basedir}/libs/mypet-3.11-20210318.180552-1.jar</systemPath>
</dependency>
</dependencies>
@ -254,7 +255,8 @@
<!-- PlaceholderAPI -->
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>
https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<!-- MyPet -->
<!--<repository> <id>mypet-repo</id> <url>https://repo.mypet-plugin.de/</url>

View File

@ -574,7 +574,7 @@ public class editquests implements Cmd {
String objectiveString = toString(objectives);
rm.addText((objectives.isEmpty() ? "&c" : "&e") + Jobs.getLanguage().getMessage("command.editquests.help.output.objectives") + (objectiveString.isBlank() ? "" : " - &f" + objectiveString));
rm.addText((objectives.isEmpty() ? "&c" : "&e") + Jobs.getLanguage().getMessage("command.editquests.help.output.objectives") + (objectiveString.isEmpty() ? "" : " - &f" + objectiveString));
rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.objectives")));
rmc = new RawMessageCommand() {
@Override
@ -588,7 +588,7 @@ public class editquests implements Cmd {
String rewardsString = toString(quest.getRewardCmds());
rm.addText((quest.getRewardCmds().isEmpty() ? "&c" : "&e") + Jobs.getLanguage().getMessage("command.editquests.help.output.rewards") + (rewardsString.isBlank() ? "" : " - &f" + rewardsString));
rm.addText((quest.getRewardCmds().isEmpty() ? "&c" : "&e") + Jobs.getLanguage().getMessage("command.editquests.help.output.rewards") + (rewardsString.isEmpty() ? "" : " - &f" + rewardsString));
rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.rewards")));
rmc = new RawMessageCommand() {
@Override
@ -601,7 +601,7 @@ public class editquests implements Cmd {
rm.addText("\n");
String descString = toString(quest.getDescription());
rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.output.description") + (rewardsString.isBlank() ? "" : " - &f" + descString));
rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.output.description") + (rewardsString.isEmpty() ? "" : " - &f" + descString));
rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.description")));
rmc = new RawMessageCommand() {
@Override
@ -614,7 +614,7 @@ public class editquests implements Cmd {
rm.addText("\n");
String restrictedString = toString(quest.getRestrictedAreas());
rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.output.areas") + (restrictedString.isBlank() ? "" : " - &f" + restrictedString));
rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.output.areas") + (restrictedString.isEmpty() ? "" : " - &f" + restrictedString));
rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.areas")));
rmc = new RawMessageCommand() {
@Override

View File

@ -26,7 +26,7 @@ public class entitylist implements Cmd {
i++;
if (!msg.isEmpty())
if (!msg.toString().isEmpty())
msg.append(LC.info_ListSpliter.getLocale());
if (i > 1) {

View File

@ -28,7 +28,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.commons.lang3.StringEscapeUtils;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -971,6 +970,53 @@ public class ConfigManager {
ItemBoostManager.load();
}
private static String escapeUnicode(String input) {
StringBuilder result = new StringBuilder(input.length());
boolean escaping = false;
for (int i = 0; i < input.length(); i++) {
char currentChar = input.charAt(i);
if (!escaping) {
if (currentChar == '\\') {
escaping = true;
} else {
result.append(currentChar);
}
} else {
switch (currentChar) {
case 'n':
result.append('\n');
break;
case 't':
result.append('\t');
break;
case 'r':
result.append('\r');
break;
case 'f':
result.append('\f');
break;
case 'b':
result.append('\b');
break;
case '\\':
result.append('\\');
break;
case '\'':
result.append('\'');
break;
case '\"':
result.append('\"');
break;
default:
result.append(currentChar);
break;
}
escaping = false;
}
}
return result.toString();
}
private Job loadJobs(ConfigurationSection jobsSection) {
java.util.logging.Logger log = Jobs.getPluginLogger();
@ -980,7 +1026,7 @@ public class ConfigManager {
continue;
// Translating unicode
jobKey = StringEscapeUtils.unescapeJava(jobKey);
jobKey = escapeUnicode(jobKey);
ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey);
if (jobSection == null)
@ -993,7 +1039,7 @@ public class ConfigManager {
}
// Translating unicode
jobFullName = StringEscapeUtils.unescapeJava(jobFullName);
jobFullName = escapeUnicode(jobFullName);
int maxLevel = jobSection.getInt("max-level");
if (maxLevel < 0)
@ -1572,8 +1618,6 @@ public class ConfigManager {
return job;
}
}
return null;
}