1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +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"?> <?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> <modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId> <groupId>Jobs</groupId>
<artifactId>jobs</artifactId> <artifactId>jobs</artifactId>
<version>5.2.1.0</version> <version>5.2.1.1</version>
<name>Jobs</name> <name>Jobs</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <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> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -199,8 +201,7 @@
<scope>system</scope> <scope>system</scope>
<systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath> <systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath>
</dependency> </dependency>
<!-- WildStacker --> <!-- WildStacker -->
<dependency> <dependency>
<groupId>com.bgsoftware</groupId> <groupId>com.bgsoftware</groupId>
<artifactId>WildStackerAPI</artifactId> <artifactId>WildStackerAPI</artifactId>
@ -222,7 +223,7 @@
<artifactId>mypet</artifactId> <artifactId>mypet</artifactId>
<version>3.11-SNAPSHOT</version> <version>3.11-SNAPSHOT</version>
<scope>system</scope> <scope>system</scope>
<!-- Temporary solution for replacing repository --> <!-- Temporary solution for replacing repository -->
<systemPath>${basedir}/libs/mypet-3.11-20210318.180552-1.jar</systemPath> <systemPath>${basedir}/libs/mypet-3.11-20210318.180552-1.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>
@ -254,7 +255,8 @@
<!-- PlaceholderAPI --> <!-- PlaceholderAPI -->
<repository> <repository>
<id>placeholderapi</id> <id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> <url>
https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository> </repository>
<!-- MyPet --> <!-- MyPet -->
<!--<repository> <id>mypet-repo</id> <url>https://repo.mypet-plugin.de/</url> <!--<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); 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"))); rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.objectives")));
rmc = new RawMessageCommand() { rmc = new RawMessageCommand() {
@Override @Override
@ -588,7 +588,7 @@ public class editquests implements Cmd {
String rewardsString = toString(quest.getRewardCmds()); 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"))); rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.rewards")));
rmc = new RawMessageCommand() { rmc = new RawMessageCommand() {
@Override @Override
@ -601,7 +601,7 @@ public class editquests implements Cmd {
rm.addText("\n"); rm.addText("\n");
String descString = toString(quest.getDescription()); 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"))); rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.description")));
rmc = new RawMessageCommand() { rmc = new RawMessageCommand() {
@Override @Override
@ -614,7 +614,7 @@ public class editquests implements Cmd {
rm.addText("\n"); rm.addText("\n");
String restrictedString = toString(quest.getRestrictedAreas()); 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"))); rm.addHover(LC.modify_editSymbolHover.getLocale("[text]", Jobs.getLanguage().getMessage("command.editquests.help.output.areas")));
rmc = new RawMessageCommand() { rmc = new RawMessageCommand() {
@Override @Override

View File

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

View File

@ -28,7 +28,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import org.apache.commons.lang3.StringEscapeUtils;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -971,6 +970,53 @@ public class ConfigManager {
ItemBoostManager.load(); 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) { private Job loadJobs(ConfigurationSection jobsSection) {
java.util.logging.Logger log = Jobs.getPluginLogger(); java.util.logging.Logger log = Jobs.getPluginLogger();
@ -980,7 +1026,7 @@ public class ConfigManager {
continue; continue;
// Translating unicode // Translating unicode
jobKey = StringEscapeUtils.unescapeJava(jobKey); jobKey = escapeUnicode(jobKey);
ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey); ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey);
if (jobSection == null) if (jobSection == null)
@ -993,7 +1039,7 @@ public class ConfigManager {
} }
// Translating unicode // Translating unicode
jobFullName = StringEscapeUtils.unescapeJava(jobFullName); jobFullName = escapeUnicode(jobFullName);
int maxLevel = jobSection.getInt("max-level"); int maxLevel = jobSection.getInt("max-level");
if (maxLevel < 0) if (maxLevel < 0)
@ -1572,8 +1618,6 @@ public class ConfigManager {
return job; return job;
} }
} }
return null; return null;
} }