Compare commits

..

1 Commits

Author SHA1 Message Date
4bc8b78224 fix: adjust nullability checks for shulkers in the kill road mobs task
- Fixes #3789
2022-10-09 15:41:16 +01:00
4 changed files with 9 additions and 14 deletions

View File

@ -866,10 +866,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
com.plotsquared.core.location.Location pLoc = BukkitUtil.adapt(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId = area.getPlotAbs(pLoc).getId();
if (!originalPlotId.equals(currentPlotId) && (currentPlotId == null || !area.getPlot(
originalPlotId)
.equals(area.getPlot(currentPlotId)))) {
Plot currentPlot = area.getPlotAbs(pLoc);
if (currentPlot == null || !originalPlotId.equals(currentPlot.getId())) {
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
@ -883,11 +881,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
com.plotsquared.core.location.Location pLoc = BukkitUtil.adapt(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId = area.getPlotAbs(pLoc).getId();
if (currentPlotId != null) {
Plot currentPlot = area.getPlotAbs(pLoc);
if (currentPlot != null) {
entity.setMetadata(
"shulkerPlot",
new FixedMetadataValue((Plugin) PlotSquared.platform(), currentPlotId)
new FixedMetadataValue((Plugin) PlotSquared.platform(), currentPlot.getId())
);
}
}

View File

@ -36,8 +36,7 @@ import java.util.regex.Pattern;
public class StringMan {
// Stolen from https://stackoverflow.com/a/366532/12620913 | Debug: https://regex101.com/r/DudJLb/1
private static final Pattern STRING_SPLIT_PATTERN = Pattern.compile("[^\\s\"]+|\"([^\"]*)\"");
private static final Pattern STRING_SPLIT_PATTERN = Pattern.compile("(?<quoted>\"[\\w ]+\")|(?<single>\\w+)");
public static String replaceFromMap(String string, Map<String, String> replacements) {
StringBuilder sb = new StringBuilder(string);
@ -356,7 +355,7 @@ public class StringMan {
var matcher = StringMan.STRING_SPLIT_PATTERN.matcher(message);
List<String> splitMessages = new ArrayList<>();
while (matcher.find()) {
splitMessages.add(matcher.group(matcher.groupCount() - 1).replaceAll("\"", ""));
splitMessages.add(matcher.group(0).replaceAll("\"", ""));
}
return splitMessages;
}

View File

@ -32,9 +32,7 @@ public class StringManTest {
new Message("title", List.of("title")),
new Message("title \"sub title\"", List.of("title", "sub title")),
new Message("\"a title\" subtitle", List.of("a title", "subtitle")),
new Message("\"title\" \"subtitle\"", List.of("title", "subtitle")),
new Message("\"How <bold>bold</bold> of you\" \"to assume I like <rainbow>rainbows</rainbow>\"",
List.of("How <bold>bold</bold> of you", "to assume I like <rainbow>rainbows</rainbow>"))
new Message("\"title\" \"subtitle\"", List.of("title", "subtitle"))
);
for (Message message : messages) {