From 38bdb929f463c08fcc0ac82faeba90980538a003 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 27 Nov 2019 23:33:42 +0100 Subject: [PATCH 01/10] Generate maven artifacts I'm not a kotlin dsl expert, but that seems to work. --- worldedit-bukkit/build.gradle.kts | 49 +++++++++++++++++++++++++++++-- worldedit-core/build.gradle.kts | 47 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 88b4bdb3e..2911a08d1 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -2,6 +2,9 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { `java-library` + maven + java + `maven-publish` } applyPlatformAndCoreConfiguration() @@ -20,8 +23,8 @@ repositories { maven { url = uri("https://repo.destroystokyo.com/repository/maven-public//") } maven { url = uri("http://repo.dmulloy2.net/content/groups/public/") } maven { url = uri("http://ci.ender.zone/plugin/repository/everything/") } - maven { url = uri("https://repo.inventivetalent.org/content/groups/public/")} - flatDir {dir(File("src/main/resources"))} + maven { url = uri("https://repo.inventivetalent.org/content/groups/public/") } + flatDir { dir(File("src/main/resources")) } } configurations.all { @@ -81,6 +84,44 @@ tasks.named("jar") { } } +val jar: Jar by tasks +jar.archiveName = "FAWE-Bukkit-API-${project.version}.jar" +jar.destinationDir = file("../mvn/com/boydti/FAWE-Bukkit-API/" + project.version) + +task("writeNewPom") { + doLast { + maven.pom { + withGroovyBuilder { + "project" { + groupId = "com.boydti" + artifactId = "FAWE-Bukkit-API" + version = "project.version" + } + } + }.writeTo("../mvn/com/boydti/FAWE-Bukkit-API/${project.version}/FAWE-Bukkit-API-${project.version}.pom") + maven.pom { + withGroovyBuilder { + "project" { + groupId = "com.boydti" + artifactId = "FAWE-Bukkit-API" + version = "latest" + } + } + }.writeTo("../mvn/com/boydti/FAWE-Bukkit-API/latest/FAWE-Bukkit-API-latest.pom") + } +} + +task("dataContent") { + doLast { + copySpec { + from("../mvn/com/boydti/FAWE-Bukkit-API/${project.version}/") + into("../mvn/com/boydti/FAWE-Bukkit-API/latest/") + include("*.jar") + rename("FAWE-Bukkit-API-${project.version}.jar", "FAWE-Bukkit-API-latest.jar") + } + } +} + tasks.named("shadowJar") { dependencies { relocate("org.slf4j", "com.sk89q.worldedit.slf4j") @@ -107,3 +148,7 @@ tasks.named("shadowJar") { tasks.named("assemble").configure { dependsOn("shadowJar") } + +tasks.named("dataContent").configure { + dependsOn("writeNewPom") +} diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index a3bb707d5..f4ec977e7 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -5,6 +5,9 @@ import com.mendhak.gradlecrowdin.UploadSourceFileTask plugins { id("java-library") + id("java") + id("maven") + id("maven-publish") id("net.ltgt.apt-eclipse") id("net.ltgt.apt-idea") id("antlr") @@ -98,6 +101,45 @@ tasks.named("processResources") { "date" to "${rootProject.ext["date"]}") } } + +val jar: Jar by tasks +jar.archiveName = "FAWE-API-${project.version}.jar" +jar.destinationDir = file("../mvn/com/boydti/FAWE-API/" + project.version) + +task("writeNewPom") { + doLast { + maven.pom { + withGroovyBuilder { + "project" { + groupId = "com.boydti" + artifactId = "FAWE-API" + version = "project.version" + } + } + }.writeTo("../mvn/com/boydti/FAWE-API/${project.version}/FAWE-API-${project.version}.pom") + maven.pom { + withGroovyBuilder { + "project" { + groupId = "com.boydti" + artifactId = "FAWE-API" + version = "latest" + } + } + }.writeTo("../mvn/com/boydti/FAWE-API/latest/FAWE-API-latest.pom") + } +} + +task("dataContent") { + doLast { + copySpec { + from("../mvn/com/boydti/FAWE-API/${project.version}/") + into("../mvn/com/boydti/FAWE-API/latest/") + include("*.jar") + rename("FAWE-API-${project.version}.jar", "FAWE-API-latest.jar") + } + } +} + tasks.named("shadowJar") { dependencies { include(dependency("com.github.luben:zstd-jni:1.4.3-1")) @@ -129,3 +171,8 @@ if (project.hasProperty(crowdinApiKey)) { dependsOn("crowdinDownload") } } + +tasks.named("dataContent").configure { + dependsOn("writeNewPom") +} + From 1b2710f82347a932495a717081804338d7a43494 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 27 Nov 2019 23:50:32 +0100 Subject: [PATCH 02/10] Remove ASkyBlock ASkyBlock does only exist up to 1.12 and won't be continued to higher versions. --- worldedit-bukkit/build.gradle.kts | 1 - .../com/boydti/fawe/bukkit/FaweBukkit.java | 10 ---- .../fawe/bukkit/regions/ASkyBlockHook.java | 47 ------------------- 3 files changed, 58 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 88b4bdb3e..74dd90fa1 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -65,7 +65,6 @@ dependencies { "implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false } "implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false } "implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { isTransitive = false } - "implementation"("com.wasteofplastic:askyblock:3.0.8.2") { isTransitive = false } } tasks.named("processResources") { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 1bc5ed32d..721a6aeab 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -12,7 +12,6 @@ import com.boydti.fawe.bukkit.listener.CFIPacketListener; import com.boydti.fawe.bukkit.listener.ChunkListener_8; import com.boydti.fawe.bukkit.listener.ChunkListener_9; import com.boydti.fawe.bukkit.listener.RenderListener; -import com.boydti.fawe.bukkit.regions.ASkyBlockHook; import com.boydti.fawe.bukkit.regions.FactionsFeature; import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature; import com.boydti.fawe.bukkit.regions.FreeBuildRegion; @@ -296,15 +295,6 @@ public class FaweBukkit implements IFawe, Listener { } } - final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock"); - if (aSkyBlock != null && aSkyBlock.isEnabled()) { - try { - managers.add(new ASkyBlockHook(aSkyBlock)); - log.debug("Attempting to use plugin 'ASkyBlock' found. Using it now."); - } catch (Throwable e) { - e.printStackTrace(); - } - } if (Settings.IMP.EXPERIMENTAL.FREEBUILD) { try { managers.add(new FreeBuildRegion()); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java deleted file mode 100644 index 84d328400..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.boydti.fawe.bukkit.regions; - -import com.boydti.fawe.regions.FaweMask; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector3; -import com.wasteofplastic.askyblock.ASkyBlockAPI; -import com.wasteofplastic.askyblock.Island; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; - -public class ASkyBlockHook extends BukkitMaskManager implements Listener { - - public ASkyBlockHook(final Plugin aSkyBlock) { - super(aSkyBlock.getName()); - - } - - public boolean isAllowed(Player player, Island island, MaskType type) { - return island != null && (player.getUniqueId().equals(island.getOwner()) || (type == MaskType.MEMBER && island.getMembers().contains(player.getUniqueId()) && hasMemberPermission(player))); - } - - @Override - public FaweMask getMask(final com.sk89q.worldedit.entity.Player player, MaskType type) { - final Location location = BukkitAdapter.adapt(player).getLocation(); - - Island island = ASkyBlockAPI.getInstance().getIslandAt(location); - if (island != null && isAllowed(BukkitAdapter.adapt(player), island, type)) { - - Location center1 = island.getCenter(); - MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ()); - BlockVector3 pos1 = BlockVector3.at(island.getMinProtectedX(), 0, island.getMinProtectedZ()); - MutableBlockVector3 pos2 = center.add(center.subtract(pos1)).mutY(255); - - return new FaweMask(pos1, pos2) { - @Override - public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { - return isAllowed(BukkitAdapter.adapt(player), island, type); - } - }; - } - - return null; - } -} From 32880e520b8296a66ba9eb57892dae8c481900b2 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 28 Nov 2019 16:34:53 +0100 Subject: [PATCH 03/10] Remove Regios - Outdated since CB 1.6.2 --- worldedit-bukkit/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 74dd90fa1..5047e5cc8 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -60,7 +60,6 @@ dependencies { "implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false } "implementation"("com.github.TechFortress:GriefPrevention:16.12.0") { isTransitive = false } "implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false } - "implementation"("net.jzx7:regios:5.9.9") { isTransitive = false } "implementation"("com.bekvon.bukkit.residence:Residence:4.5._13.1") { isTransitive = false } "implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false } "implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false } From 0f1715ea9ff610519a9f2a92f34af2e94226f4a0 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 29 Nov 2019 14:28:06 +0100 Subject: [PATCH 04/10] Revert "Merge pull request #274 from IntellectualSites/api" This reverts commit 79d9bda9129790ef7d7d2d06c0e4410c1bed259a, reversing changes made to 0fcac395929d7d4e511f7f05b16973baa55bcf00. --- worldedit-bukkit/build.gradle.kts | 49 ++----------------------------- worldedit-core/build.gradle.kts | 47 ----------------------------- 2 files changed, 2 insertions(+), 94 deletions(-) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 2911a08d1..88b4bdb3e 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -2,9 +2,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { `java-library` - maven - java - `maven-publish` } applyPlatformAndCoreConfiguration() @@ -23,8 +20,8 @@ repositories { maven { url = uri("https://repo.destroystokyo.com/repository/maven-public//") } maven { url = uri("http://repo.dmulloy2.net/content/groups/public/") } maven { url = uri("http://ci.ender.zone/plugin/repository/everything/") } - maven { url = uri("https://repo.inventivetalent.org/content/groups/public/") } - flatDir { dir(File("src/main/resources")) } + maven { url = uri("https://repo.inventivetalent.org/content/groups/public/")} + flatDir {dir(File("src/main/resources"))} } configurations.all { @@ -84,44 +81,6 @@ tasks.named("jar") { } } -val jar: Jar by tasks -jar.archiveName = "FAWE-Bukkit-API-${project.version}.jar" -jar.destinationDir = file("../mvn/com/boydti/FAWE-Bukkit-API/" + project.version) - -task("writeNewPom") { - doLast { - maven.pom { - withGroovyBuilder { - "project" { - groupId = "com.boydti" - artifactId = "FAWE-Bukkit-API" - version = "project.version" - } - } - }.writeTo("../mvn/com/boydti/FAWE-Bukkit-API/${project.version}/FAWE-Bukkit-API-${project.version}.pom") - maven.pom { - withGroovyBuilder { - "project" { - groupId = "com.boydti" - artifactId = "FAWE-Bukkit-API" - version = "latest" - } - } - }.writeTo("../mvn/com/boydti/FAWE-Bukkit-API/latest/FAWE-Bukkit-API-latest.pom") - } -} - -task("dataContent") { - doLast { - copySpec { - from("../mvn/com/boydti/FAWE-Bukkit-API/${project.version}/") - into("../mvn/com/boydti/FAWE-Bukkit-API/latest/") - include("*.jar") - rename("FAWE-Bukkit-API-${project.version}.jar", "FAWE-Bukkit-API-latest.jar") - } - } -} - tasks.named("shadowJar") { dependencies { relocate("org.slf4j", "com.sk89q.worldedit.slf4j") @@ -148,7 +107,3 @@ tasks.named("shadowJar") { tasks.named("assemble").configure { dependsOn("shadowJar") } - -tasks.named("dataContent").configure { - dependsOn("writeNewPom") -} diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index f4ec977e7..a3bb707d5 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -5,9 +5,6 @@ import com.mendhak.gradlecrowdin.UploadSourceFileTask plugins { id("java-library") - id("java") - id("maven") - id("maven-publish") id("net.ltgt.apt-eclipse") id("net.ltgt.apt-idea") id("antlr") @@ -101,45 +98,6 @@ tasks.named("processResources") { "date" to "${rootProject.ext["date"]}") } } - -val jar: Jar by tasks -jar.archiveName = "FAWE-API-${project.version}.jar" -jar.destinationDir = file("../mvn/com/boydti/FAWE-API/" + project.version) - -task("writeNewPom") { - doLast { - maven.pom { - withGroovyBuilder { - "project" { - groupId = "com.boydti" - artifactId = "FAWE-API" - version = "project.version" - } - } - }.writeTo("../mvn/com/boydti/FAWE-API/${project.version}/FAWE-API-${project.version}.pom") - maven.pom { - withGroovyBuilder { - "project" { - groupId = "com.boydti" - artifactId = "FAWE-API" - version = "latest" - } - } - }.writeTo("../mvn/com/boydti/FAWE-API/latest/FAWE-API-latest.pom") - } -} - -task("dataContent") { - doLast { - copySpec { - from("../mvn/com/boydti/FAWE-API/${project.version}/") - into("../mvn/com/boydti/FAWE-API/latest/") - include("*.jar") - rename("FAWE-API-${project.version}.jar", "FAWE-API-latest.jar") - } - } -} - tasks.named("shadowJar") { dependencies { include(dependency("com.github.luben:zstd-jni:1.4.3-1")) @@ -171,8 +129,3 @@ if (project.hasProperty(crowdinApiKey)) { dependsOn("crowdinDownload") } } - -tasks.named("dataContent").configure { - dependsOn("writeNewPom") -} - From c5a9436174844182aecf6bdcebb7cf86c57bff63 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 9 Dec 2019 18:08:44 +0100 Subject: [PATCH 05/10] Update links --- .../src/main/java/com/boydti/fawe/config/Settings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java index 38189d7da..a02b6a7e9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java @@ -21,7 +21,7 @@ public class Settings extends Config { @Final // Indicates that this value isn't configurable public String ISSUES = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues"; @Final - public String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/"; + public String WIKI = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki"; @Final public String DATE; // These values are set from FAWE before loading @Final @@ -364,7 +364,7 @@ public class Settings extends Config { @Comment({ "[SAFE] Experimental scripting support for Java 9", - " - https://github.com/boy0001/FastAsyncWorldedit/wiki/JavaScript-API" + " - https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki/JavaScript-API" }) public boolean MODERN_CRAFTSCRIPTS = false; From 80d7b0582f4673695b61d1841af6cda4bc2391a2 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 9 Dec 2019 20:07:57 +0100 Subject: [PATCH 06/10] i18n upstream merge --- .gitignore | 3 ++ .../sk89q/worldedit/bukkit/BukkitPlayer.java | 3 +- .../sk89q/worldedit/LocalConfiguration.java | 10 ++++- .../worldedit/command/SelectionCommands.java | 8 ++-- .../worldedit/command/WorldEditCommands.java | 2 +- .../command/util/AsyncCommandBuilder.java | 4 +- .../worldedit/function/factory/Deform.java | 23 +++++------ .../function/operation/ForwardExtentCopy.java | 38 ++++++++----------- .../function/operation/Operation.java | 15 ++++++++ .../function/visitor/BreadthFirstSearch.java | 4 +- .../function/visitor/EntityVisitor.java | 3 +- .../function/visitor/FlatRegionVisitor.java | 3 +- .../function/visitor/RegionVisitor.java | 3 +- .../worldedit/regions/RegionSelector.java | 24 ++++++------ .../util/PropertiesConfiguration.java | 8 +--- .../worldedit/util/YAMLConfiguration.java | 8 +--- .../util/formatting/WorldEditText.java | 2 +- .../util/formatting/component/TextUtils.java | 10 +++++ .../worldedit/util/io/ResourceLoader.java | 22 +++++------ .../util/translation/TranslationManager.java | 34 +++++++---------- .../src/main/resources/lang/.gitignore | 1 - .../src/main/resources/lang/strings.json | 1 - .../sk89q/worldedit/forge/ForgePlayer.java | 3 +- .../config/ConfigurateConfiguration.java | 8 +--- 24 files changed, 121 insertions(+), 119 deletions(-) delete mode 100644 worldedit-core/src/main/resources/lang/.gitignore diff --git a/.gitignore b/.gitignore index b33e539e0..abbab0e31 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ todo.txt mvn/* docs/ *.sh +# i18n +worldedit-core/src/main/resources/lang/* +!worldedit-core/src/main/resources/lang/strings.json diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 751d915c5..e25697834 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.config.Caption; +import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RunnableVal; @@ -280,7 +281,7 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public Locale getLocale() { - return Locale.forLanguageTag(player.getLocale().replace('_', '-')); + return TextUtils.getLocaleByMinecraftTag(player.getLocale()); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 7725376f6..49a7f39df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockMaskBuilder; +import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -210,5 +211,12 @@ public abstract class LocalConfiguration { return item; } - + public void setDefaultLocaleName(String localeName) { + this.defaultLocaleName = localeName; + if (localeName.equals("default")) { + this.defaultLocale = Locale.getDefault(); + } else { + this.defaultLocale = TextUtils.getLocaleByMinecraftTag(localeName); + } + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index d28f4d8bb..9a0d08b61 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -312,7 +312,7 @@ public class SelectionCommands { ) @CommandPermissions("worldedit.wand.toggle") public void toggleWand(Player player) { - player.print(TextComponent.of("The selection wand is now a normal tool. You can disable it with ") + player.printInfo(TextComponent.of("The selection wand is now a normal tool. You can disable it with ") .append(TextComponent.of("/none", TextColor.AQUA).clickEvent( ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/none"))) .append(TextComponent.of(" and rebind it to any item with ")) @@ -383,7 +383,7 @@ public class SelectionCommands { session.getRegionSelector(world).explainRegionAdjust(actor, session); - actor.print(TranslatableComponent.of("worldedit.shift.shifted")); + actor.printInfo(TranslatableComponent.of("worldedit.shift.shifted")); } catch (RegionOperationException e) { actor.printError(TextComponent.of(e.getMessage())); } @@ -406,7 +406,7 @@ public class SelectionCommands { region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).explainRegionAdjust(actor, session); - actor.print(TranslatableComponent.of("worldedit.outset.outset")); + actor.printInfo(TranslatableComponent.of("worldedit.outset.outset")); } @Command( @@ -426,7 +426,7 @@ public class SelectionCommands { region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).explainRegionAdjust(actor, session); - actor.print(TranslatableComponent.of("worldedit.inset.inset")); + actor.printInfo(TranslatableComponent.of("worldedit.inset.inset")); } private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 45d415c28..138f5bee3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -186,7 +186,7 @@ public class WorldEditCommands { actor.printInfo(TranslatableComponent.of("worldedit.timezone.set", TextComponent.of(tz.getDisplayName( TextStyle.FULL, actor.getLocale() )))); - actor.print(TranslatableComponent.of("worldedit.timezone.current", + actor.printInfo(TranslatableComponent.of("worldedit.timezone.current", TextComponent.of(dateFormat.withLocale(actor.getLocale()).format(ZonedDateTime.now(tz))))); } catch (ZoneRulesException e) { actor.printError(TranslatableComponent.of("worldedit.timezone.invalid")); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java index 7760d1bb9..4543ac224 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java @@ -166,13 +166,13 @@ public final class AsyncCommandBuilder { message = converted.getRichMessage(); } } - sender.print(failure.append(TextComponent.of(": ")).append(message)); + sender.printError(failure.append(TextComponent.of(": ")).append(message)); } } else { throw orig; } } catch (Throwable unknown) { - sender.print(failure.append(TextComponent.of(": Unknown error. Please see console."))); + sender.printError(failure.append(TextComponent.of(": Unknown error. Please see console."))); logger.error("Uncaught exception occurred in task: " + description, orig); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java index 2aca7cd7d..9bb608bba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java @@ -19,10 +19,7 @@ package com.sk89q.worldedit.function.factory; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -42,8 +39,8 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; -import java.util.Collection; -import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; public class Deform implements Contextual { @@ -160,6 +157,12 @@ public class Deform implements Contextual { session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout()); } + public enum Mode { + RAW_COORD, + OFFSET, + UNIT_CUBE + } + private static final class DeformOperation implements Operation { private final Extent destination; private final Region region; @@ -195,16 +198,10 @@ public class Deform implements Contextual { @Override public Iterable getStatusMessages() { - return Lists.newArrayList(TranslatableComponent.of("worldedit.operation.deform.expression", + return ImmutableList.of(TranslatableComponent.of("worldedit.operation.deform.expression", TextComponent.of(expression).color(TextColor.GRAY))); } } - public enum Mode { - RAW_COORD, - OFFSET, - UNIT_CUBE - } - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index 1c3f68a20..8b46bb04e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -19,54 +19,49 @@ package com.sk89q.worldedit.function.operation; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.extent.BlockTranslateExtent; import com.boydti.fawe.object.extent.PositionTransformExtent; import com.boydti.fawe.object.function.block.BiomeCopy; import com.boydti.fawe.object.function.block.CombinedBlockCopy; import com.boydti.fawe.object.function.block.SimpleBlockCopy; import com.boydti.fawe.util.MaskTraverser; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.metadata.EntityProperties; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.CombinedRegionFunction; -import com.sk89q.worldedit.function.FlatRegionFunction; -import com.sk89q.worldedit.function.FlatRegionMaskingFilter; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionMaskTestFunction; -import com.sk89q.worldedit.function.biome.ExtentBiomeCopy; import com.sk89q.worldedit.function.RegionMaskingFilter; import com.sk89q.worldedit.function.entity.ExtentEntityCopy; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; -import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.visitor.EntityVisitor; +import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; import com.sk89q.worldedit.function.visitor.IntersectRegionFunction; import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.entity.EntityTypes; -import java.util.Collections; import com.sk89q.worldedit.util.formatting.text.Component; -import java.util.List; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import com.sk89q.worldedit.world.entity.EntityTypes; -import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Makes a copy of a portion of one extent to another extent or another point. * @@ -428,15 +423,14 @@ public class ForwardExtentCopy implements Operation { @Override public Iterable getStatusMessages() { - List messages = new ArrayList<>(); - messages.add(TranslatableComponent.of("worldedit.operation.affected.block", - TextComponent.of(affectedBlocks)).color(TextColor.GRAY)); - messages.add(TranslatableComponent.of("worldedit.operation.affected.biome", - TextComponent.of(affectedBiomeCols)).color(TextColor.GRAY)); - messages.add(TranslatableComponent.of("worldedit.operation.affected.entity", - TextComponent.of(affectedEntities)).color(TextColor.GRAY)); - - return messages; + return ImmutableList.of( + TranslatableComponent.of("worldedit.operation.affected.block", + TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE), + TranslatableComponent.of("worldedit.operation.affected.biome", + TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE), + TranslatableComponent.of("worldedit.operation.affected.entity", + TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE) + ); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/Operation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/Operation.java index 5ae25eb2b..c21f2a6f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/Operation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/Operation.java @@ -19,12 +19,15 @@ package com.sk89q.worldedit.function.operation; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; /** @@ -35,6 +38,11 @@ import java.util.stream.Collectors; */ public interface Operation { + /** + * This is an internal field, and should not be touched. + */ + Set warnedDeprecatedClasses = new HashSet<>(); + /** * Complete the next step. If this method returns true, then the method may * be called again in the future, or possibly never. If this method @@ -76,6 +84,13 @@ public interface Operation { // TODO Remove legacy code WorldEdit 8.0.0 List oldMessages = new ArrayList<>(); addStatusMessages(oldMessages); + if (oldMessages.size() > 0) { + String className = getClass().getName(); + if (!warnedDeprecatedClasses.contains(className)) { + WorldEdit.logger.warn("An operation is using the old status message API. This will be removed in further versions. Class: " + className); + warnedDeprecatedClasses.add(className); + } + } return oldMessages.stream().map(TextComponent::of).collect(Collectors.toList()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 10efa0c9b..e85b7a4f1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.visitor; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.collection.BlockVectorSet; @@ -279,7 +279,7 @@ public abstract class BreadthFirstSearch implements Operation { @Override public Iterable getStatusMessages() { - return Lists.newArrayList(TranslatableComponent.of( + return ImmutableList.of(TranslatableComponent.of( "worldedit.operation.affected.block", TextComponent.of(getAffected()) ).color(TextColor.GRAY)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java index bdfb9dcc0..9d4405ca2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.function.visitor; +import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import static com.google.common.base.Preconditions.checkNotNull; @@ -84,7 +85,7 @@ public class EntityVisitor implements Operation { @Override public Iterable getStatusMessages() { - return Lists.newArrayList(TranslatableComponent.of( + return ImmutableList.of(TranslatableComponent.of( "worldedit.operation.affected.entity", TextComponent.of(getAffected()) ).color(TextColor.GRAY)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java index ba43aca0b..799f69bb1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.function.visitor; +import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.google.common.collect.Lists; @@ -83,7 +84,7 @@ public class FlatRegionVisitor implements Operation { @Override public Iterable getStatusMessages() { - return Lists.newArrayList(TranslatableComponent.of( + return ImmutableList.of(TranslatableComponent.of( "worldedit.operation.affected.column", TextComponent.of(getAffected()) ).color(TextColor.GRAY)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java index 89f4123b2..309da923a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.function.visitor; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; @@ -95,7 +96,7 @@ public class RegionVisitor implements Operation { @Override public Iterable getStatusMessages() { - return Lists.newArrayList(TranslatableComponent.of( + return ImmutableList.of(TranslatableComponent.of( "worldedit.operation.affected.block", TextComponent.of(getAffected()) ).color(TextColor.GRAY)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java index 72a7f170c..2e257ce69 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java @@ -20,22 +20,21 @@ package com.sk89q.worldedit.regions; import com.google.common.collect.Lists; - import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import com.sk89q.worldedit.world.World; +import javax.annotation.Nullable; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nullable; - /** * Region selectors create {@link Region}s from a series of "selected points." * They are used, for example, to allow users to create a {@link CuboidRegion} @@ -77,8 +76,8 @@ public interface RegionSelector { /** * Tell the player information about his/her primary selection. * - * @param actor the actor - * @param session the session + * @param actor the actor + * @param session the session * @param position position */ void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position); @@ -86,8 +85,8 @@ public interface RegionSelector { /** * Tell the player information about his/her secondary selection. * - * @param actor the actor - * @param session the session + * @param actor the actor + * @param session the session * @param position position */ void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position); @@ -96,7 +95,7 @@ public interface RegionSelector { * The the player information about the region's changes. This may resend * all the defining region information if needed. * - * @param actor the actor + * @param actor the actor * @param session the session */ void explainRegionAdjust(Actor actor, LocalSession session); @@ -157,13 +156,13 @@ public interface RegionSelector { /** * Get lines of information about the selection. - * + * * @return a list of lines describing the region */ @Deprecated default List getInformationLines() { return Lists.newArrayList(); - }; + } /** * Get lines of information about the selection. @@ -172,12 +171,13 @@ public interface RegionSelector { */ default List getSelectionInfoLines() { return getInformationLines().stream() - .map(TextComponent::of) + .map(line -> TextComponent.of(line, TextColor.LIGHT_PURPLE)) .collect(Collectors.toList()); } /** * Get the vertices + * * @return * @throws IncompleteRegionException */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index fce840b40..d09c30d3a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -39,7 +39,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.HashSet; -import java.util.Locale; import java.util.Properties; import java.util.Set; @@ -123,12 +122,7 @@ public class PropertiesConfiguration extends LocalConfiguration { allowSymlinks = getBool("allow-symbolic-links", allowSymlinks); serverSideCUI = getBool("server-side-cui", serverSideCUI); extendedYLimit = getBool("extended-y-limit", extendedYLimit); - defaultLocaleName = getString("default-locale", defaultLocaleName); - if (defaultLocaleName.equals("default")) { - defaultLocale = Locale.getDefault(); - } else { - defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-')); - } + setDefaultLocaleName(getString("default-locale", defaultLocaleName)); LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index 9a3dc841f..6cc54bdf3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -30,7 +30,6 @@ import org.slf4j.Logger; import java.io.IOException; import java.util.HashSet; -import java.util.Locale; /** * A less simple implementation of {@link LocalConfiguration} @@ -128,12 +127,7 @@ public class YAMLConfiguration extends LocalConfiguration { extendedYLimit = config.getBoolean("compat.extended-y-limit", false); - defaultLocaleName = config.getString("default-locale", defaultLocaleName); - if (defaultLocaleName.equals("default")) { - defaultLocale = Locale.getDefault(); - } else { - defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-')); - } + setDefaultLocaleName(config.getString("default-locale", defaultLocaleName)); } public void unload() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java index 1e2b0728e..e448926fc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java @@ -35,7 +35,7 @@ public class WorldEditText { } public static Component format(Component component, Locale locale) { - return CONFIG_HOLDER.replace(WorldEdit.getInstance().getTranslationManager().convertText(component, locale)); + return WorldEdit.getInstance().getTranslationManager().convertText(CONFIG_HOLDER.replace(component), locale); } public static String reduceToText(Component component, Locale locale) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/TextUtils.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/TextUtils.java index f604d322a..8540ed3b1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/TextUtils.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/TextUtils.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import java.util.List; +import java.util.Locale; public class TextUtils { @@ -46,4 +47,13 @@ public class TextUtils { } return builder.build(); } + /** + * Gets a Java Locale object by the Minecraft locale tag. + * + * @param locale The Minecraft locale tag + * @return A Java locale + */ + public static Locale getLocaleByMinecraftTag(String locale) { + return Locale.forLanguageTag(locale.replace('_', '-')); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java index 0ce49b115..e3aaca134 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java @@ -28,18 +28,18 @@ public class ResourceLoader { } private static URL getResourceForgeHack(String location) throws IOException { - return new URL("modjar://worldedit/" + location); + try { + return new URL("modjar://worldedit/" + location); + } catch (Exception e) { + throw new IOException("Could not find " + location); + } } public static URL getResource(Class clazz, String name) throws IOException { URL url = clazz.getResource(name); if (url == null) { - try { - return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/") - + "/" + name); - } catch (Exception e) { - throw new IOException("Could not find " + name); - } + return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/") + + "/" + name); } return url; } @@ -47,12 +47,8 @@ public class ResourceLoader { public static URL getResourceRoot(String name) throws IOException { URL url = ResourceLoader.class.getResource("/" + name); if (url == null) { - try { - return getResourceForgeHack(name); - } catch (Exception e) { - throw new IOException("Could not find " + name); - } + return getResourceForgeHack(name); } return url; } -} +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java index 46984ce82..656430038 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java @@ -19,8 +19,7 @@ package com.sk89q.worldedit.util.translation; -import com.google.common.io.Files; -import com.google.common.io.Resources; +import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; @@ -29,21 +28,14 @@ import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer; import com.sk89q.worldedit.util.io.ResourceLoader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.lang.reflect.Type; -import java.net.URL; -import java.nio.charset.StandardCharsets; import java.text.MessageFormat; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +import static java.util.stream.Collectors.toMap; + /** * Handles translations for the plugin. @@ -62,7 +54,7 @@ public class TranslationManager { private static final Gson gson = new GsonBuilder().create(); private static final Type STRING_MAP_TYPE = new TypeToken>() {}.getType(); - private final Map> translationMap = new HashMap<>(); + private final Map> translationMap = new ConcurrentHashMap<>(); private final FriendlyComponentRenderer friendlyComponentRenderer = FriendlyComponentRenderer.from( (locale, key) -> new MessageFormat(getTranslationMap(locale).getOrDefault(key, key), locale)); private Locale defaultLocale = Locale.ENGLISH; @@ -80,8 +72,10 @@ public class TranslationManager { } private Map filterTranslations(Map translations) { - translations.entrySet().removeIf(entry -> entry.getValue().isEmpty()); - return translations; + return translations.entrySet().stream() + .filter(e -> !e.getValue().isEmpty()) + .map(e -> Maps.immutableEntry(e.getKey(), e.getValue().replace("'", "''"))) + .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); } private Map parseTranslationFile(InputStream inputStream) { @@ -95,7 +89,7 @@ public class TranslationManager { baseTranslations = parseTranslationFile(ResourceLoader.getResourceRoot("lang/" + filename).openStream()); } catch (IOException e) { // Seem to be missing base. If the user has provided a file use that. - baseTranslations = new HashMap<>(); + baseTranslations = new ConcurrentHashMap<>(); } File localFile = worldEdit.getWorkingDirectoryFile("lang/" + filename); @@ -117,7 +111,7 @@ public class TranslationManager { } checkedLocales.add(locale); // Make a copy of the default language file - Map baseTranslations = new HashMap<>(); + Map baseTranslations = new ConcurrentHashMap<>(); if (!locale.equals(defaultLocale)) { baseTranslations.putAll(getTranslationMap(defaultLocale)); } diff --git a/worldedit-core/src/main/resources/lang/.gitignore b/worldedit-core/src/main/resources/lang/.gitignore deleted file mode 100644 index 0a00d7014..000000000 --- a/worldedit-core/src/main/resources/lang/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*/ \ No newline at end of file diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 6eb93906b..fc90b4189 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -13,7 +13,6 @@ "fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}", "fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info", - "fawe.info.lighting.propagate.selection": "Lighting has been propogated in {0} chunks. (Note: To remove light use //removelight)", "fawe.info.updated.lighting.selection": "Lighting has been updated in {0} chunks. (It may take a second for the packets to send)", "fawe.info.set.region": "Selection set to your current allowed region", diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 0ac91396e..551a83f67 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.WorldEditText; +import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer; @@ -209,7 +210,7 @@ public class ForgePlayer extends AbstractPlayerActor { @Override public Locale getLocale() { - return Locale.forLanguageTag(player.language.replace('_', '-')); + return TextUtils.getLocaleByMinecraftTag(player.language); } @Override diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index e9808c99e..350a7c9a6 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -34,7 +34,6 @@ import org.slf4j.Logger; import java.io.IOException; import java.util.HashSet; -import java.util.Locale; public class ConfigurateConfiguration extends LocalConfiguration { @@ -131,11 +130,6 @@ public class ConfigurateConfiguration extends LocalConfiguration { shellSaveType = type.equals("") ? null : type; extendedYLimit = node.getNode("compat", "extended-y-limit").getBoolean(false); - defaultLocaleName = node.getNode("default-locale").getString(defaultLocaleName); - if (defaultLocaleName.equals("default")) { - defaultLocale = Locale.getDefault(); - } else { - defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-')); - } + setDefaultLocaleName(node.getNode("default-locale").getString(defaultLocaleName)); } } From a058f13d6eca7679a92c1bdf82e55d2fdb3fdd6c Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 9 Dec 2019 21:34:26 +0100 Subject: [PATCH 07/10] Updates --- build.gradle.kts | 2 +- splash.txt | 21 ----------------- .../bukkit/BukkitBlockCommandSender.java | 22 ++++++++---------- .../command/argument/FactoryConverter.java | 5 ++-- worldedit-logo.png | Bin 9124 -> 0 bytes 5 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 splash.txt delete mode 100644 worldedit-logo.png diff --git a/build.gradle.kts b/build.gradle.kts index a208e540e..c8795df6c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,7 @@ logger.lifecycle(""" 1) Read COMPILING.md if you haven't yet 2) Try running 'build' in a separate Gradle run 3) Use gradlew and not gradle - 4) If you still need help, ask on Discord! https://discord.gg/enginehub + 4) If you still need help, ask on Discord! https://discord.gg/ngZCzbU Output files will be in [subproject]/build/libs ******************************************* diff --git a/splash.txt b/splash.txt deleted file mode 100644 index 6513022a7..000000000 --- a/splash.txt +++ /dev/null @@ -1,21 +0,0 @@ - -============= You are compiling: ============= - _______ ___ ____ __ ____ _______ -| ____| / \ \ \ / \ / / | ____| -| |__ / ^ \ \ \/ \/ / | |__ -| __| / /_\ \ \ / | __| -| | / _____ \ \ /\ / | |____ -|__| /__/ \__\ \__/ \__/ |_______| - -======== Authors https://git.io/fjIDU ======== - -If you encounter trouble: - - Run `build` in a separate Gradle run - - Use gradlew and not gradle - - Ask us! - - https://discord.gg/ngZCzbU (Discord) - -Files will be output to `/target` - -============================================== - diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java index 58d4f12bf..3c293f6f3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -19,10 +19,7 @@ package com.sk89q.worldedit.bukkit; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEdit; - import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.Extent; @@ -31,22 +28,24 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; -import com.sk89q.worldedit.util.formatting.text.format.TextColor; -import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.BlockCommandSender; - -import java.util.Locale; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.nio.charset.StandardCharsets; +import java.util.Locale; +import java.util.UUID; + +import static com.google.common.base.Preconditions.checkNotNull; + public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable { + private static final String UUID_PREFIX = "CMD"; + private final BlockCommandSender sender; private final WorldEditPlugin plugin; private final Location location; @@ -59,7 +58,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements this.plugin = plugin; this.sender = sender; this.location = BukkitAdapter.adapt(sender.getBlock().getLocation()); - this.uuid = new UUID(location.toVector().toBlockPoint().hashCode(), location.getExtent().hashCode()); + this.uuid = UUID.nameUUIDFromBytes((UUID_PREFIX + sender.getName()).getBytes(StandardCharsets.UTF_8)); } @Override @@ -134,7 +133,6 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements @Override public SessionKey getSessionKey() { return new SessionKey() { - @Nullable @Override public String getName() { return sender.getName(); @@ -154,7 +152,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements @Override public boolean isPersistent() { - return false; + return true; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java index d475c387c..5b880f726 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java @@ -27,6 +27,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.mask.Mask; @@ -104,8 +105,8 @@ public class FactoryConverter implements ArgumentConverter { ParserContext parserContext = new ParserContext(); parserContext.setActor(actor); - if (actor instanceof Entity) { - Extent extent = ((Entity) actor).getExtent(); + if (actor instanceof Locatable) { + Extent extent = ((Locatable) actor).getExtent(); if (extent instanceof World) { parserContext.setWorld((World) extent); } diff --git a/worldedit-logo.png b/worldedit-logo.png deleted file mode 100644 index e0b515743ce40641cfdc045b1bc0e9e28dc32fe2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9124 zcmaKSWmp^S+AS1mad#+?;;zM^NRT2$g1bYJ1a~i9q);463lz8F?tun(FYZtrg7-_` zZ|{B1kF(GGNSLag7Dqxtp|c0+x$CK_h+2Z3xXl0B zaCtjH5NISMaVc+zxut`(JDr8Kt-Z4Z;H0$^Kxc0y0nimxDybmHEk2m&W-cXK*#Cr4*DQEv&rKfI!d_21Ln0J?un+#MtU{~MH^sydx4 z*wva&kc)@YlIJxK-D_ShUVZ@~At4SrJ|12kZXP~vUOrA=W97h>9!}QI?*GPG{Rb=0^Ix%l2f+z~@GNKT zYVT=nCGQG$qWdRdQTzWMi`;+Z`xn;gzs3Rt{#PtFA{g$!ZT-L6{O?nU+4;Nt&(I<^ z{~3F0XT+?#B8HkU-Uo<;L`SJ4Ck^smJTk^e2SM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sA zqu Date: Mon, 9 Dec 2019 21:59:51 +0100 Subject: [PATCH 08/10] More updates --- .../world/registry/LegacyMapper.java | 76 +++++++++---------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index 05fa97cb2..b49b59a5e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -21,24 +21,24 @@ package com.sk89q.worldedit.world.registry; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import com.google.common.io.Resources; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.factory.BlockFactory; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.io.ResourceLoader; import com.sk89q.worldedit.world.DataFixer; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; @@ -49,13 +49,14 @@ import javax.annotation.Nullable; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; -import java.util.Map; import java.util.HashMap; +import java.util.Map; public final class LegacyMapper { private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class); private static LegacyMapper INSTANCE = new LegacyMapper(); + static { try { INSTANCE.loadFromResource(); @@ -64,12 +65,15 @@ public final class LegacyMapper { } } - private Map blockEntries = new HashMap<>(); - private final Int2ObjectArrayMap blockStateToLegacyId4Data = new Int2ObjectArrayMap<>(); private final Int2ObjectArrayMap extraId4DataToStateId = new Int2ObjectArrayMap<>(); private final int[] blockArr = new int[4096]; private final BiMap itemMap = HashBiMap.create(); + private Map blockEntries = new HashMap<>(); + private Map stringToBlockMap = new HashMap<>(); + private Multimap blockToStringMap = HashMultimap.create(); + private Map stringToItemMap = new HashMap<>(); + private Multimap itemToStringMap = HashMultimap.create(); /** * Create a new instance. @@ -77,6 +81,10 @@ public final class LegacyMapper { private LegacyMapper() { } + public final static LegacyMapper getInstance() { + return INSTANCE; + } + /** * Attempt to load the data from file. * @@ -91,7 +99,8 @@ public final class LegacyMapper { throw new IOException("Could not find legacy.json"); } String source = Resources.toString(url, Charset.defaultCharset()); - LegacyDataFile dataFile = gson.fromJson(source, new TypeToken() {}.getType()); + LegacyDataFile dataFile = gson.fromJson(source, new TypeToken() { + }.getType()); DataFixer fixer = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataFixer(); ParserContext parserContext = new ParserContext(); @@ -101,40 +110,33 @@ public final class LegacyMapper { for (Map.Entry blockEntry : dataFile.blocks.entrySet()) { String id = blockEntry.getKey(); - Integer combinedId = getCombinedId(blockEntry.getKey()); final String value = blockEntry.getValue(); blockEntries.put(id, value); - BlockState blockState = null; - try { - blockState = BlockState.get(null, blockEntry.getValue()); - BlockType type = blockState.getBlockType(); - if (type.hasProperty(PropertyKey.WATERLOGGED)) { - blockState = blockState.with(PropertyKey.WATERLOGGED, false); - } - } catch (InputParseException e) { - if (fixer != null) { + BlockState blockState = null; + BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory(); + + if (fixer != null) { + try { String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631); - try { - blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(newEntry, parserContext).toImmutableState(); - } catch (InputParseException ignored) {} - } - if (blockState == null) { - log.warn("Unknown block: " + value); - continue; + blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState(); + } catch (InputParseException e) { } } - blockArr[combinedId] = blockState.getInternalId(); - blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId); - blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId); - } - for (int id = 0; id < 256; id++) { - int combinedId = id << 4; - int base = blockArr[combinedId]; - if (base != 0) { - for (int data = 0; data < 16; data++, combinedId++) { - if (blockArr[combinedId] == 0) blockArr[combinedId] = base; + // if it's still null, the fixer was unavailable or failed + if (blockState == null) { + try { + blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState(); + } catch (InputParseException e) { } } + // if it's still null, both fixer and default failed + if (blockState == null) { + log.warn("Unknown block: " + value); + } else { + // it's not null so one of them succeeded, now use it + blockToStringMap.put(blockState, id); + stringToBlockMap.put(id, blockState); + } } for (Map.Entry itemEntry : dataFile.items.entrySet()) { @@ -265,11 +267,7 @@ public final class LegacyMapper { @Deprecated public int[] getLegacyFromBlock(BlockState blockState) { Integer combinedId = getLegacyCombined(blockState); - return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF }; - } - - public final static LegacyMapper getInstance() { - return INSTANCE; + return combinedId == null ? null : new int[]{combinedId >> 4, combinedId & 0xF}; } @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) From 39b60aa7428eb26287442ca297b0eb1e77148b0d Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 9 Dec 2019 22:36:52 +0100 Subject: [PATCH 09/10] Fix legacy id conversion --- .../world/registry/LegacyMapper.java | 71 ++++++++++++------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index b49b59a5e..f4af74483 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -33,6 +33,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.io.ResourceLoader; import com.sk89q.worldedit.world.DataFixer; @@ -81,10 +82,6 @@ public final class LegacyMapper { private LegacyMapper() { } - public final static LegacyMapper getInstance() { - return INSTANCE; - } - /** * Attempt to load the data from file. * @@ -110,33 +107,53 @@ public final class LegacyMapper { for (Map.Entry blockEntry : dataFile.blocks.entrySet()) { String id = blockEntry.getKey(); + Integer combinedId = getCombinedId(blockEntry.getKey()); final String value = blockEntry.getValue(); blockEntries.put(id, value); BlockState blockState = null; - BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory(); - - if (fixer != null) { - try { - String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631); - blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState(); - } catch (InputParseException e) { + try { + blockState = BlockState.get(null, blockEntry.getValue()); + BlockType type = blockState.getBlockType(); + if (type.hasProperty(PropertyKey.WATERLOGGED)) { + blockState = blockState.with(PropertyKey.WATERLOGGED, false); + } + } catch (InputParseException e) { + BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory(); + if (fixer != null) { + try { + String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631); + blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState(); + } catch (InputParseException f) { + } + } + // if it's still null, the fixer was unavailable or failed + if (blockState == null) { + try { + blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState(); + } catch (InputParseException f) { + } + } + // if it's still null, both fixer and default failed + if (blockState == null) { + log.warn("Unknown block: " + value); + } else { + // it's not null so one of them succeeded, now use it + blockToStringMap.put(blockState, id); + stringToBlockMap.put(id, blockState); } } - // if it's still null, the fixer was unavailable or failed - if (blockState == null) { - try { - blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState(); - } catch (InputParseException e) { + blockArr[combinedId] = blockState.getInternalId(); + blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId); + blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId); + } + for (int id = 0; id < 256; id++) { + int combinedId = id << 4; + int base = blockArr[combinedId]; + if (base != 0) { + for (int data = 0; data < 16; data++, combinedId++) { + if (blockArr[combinedId] == 0) blockArr[combinedId] = base; } } - // if it's still null, both fixer and default failed - if (blockState == null) { - log.warn("Unknown block: " + value); - } else { - // it's not null so one of them succeeded, now use it - blockToStringMap.put(blockState, id); - stringToBlockMap.put(id, blockState); - } } for (Map.Entry itemEntry : dataFile.items.entrySet()) { @@ -267,7 +284,11 @@ public final class LegacyMapper { @Deprecated public int[] getLegacyFromBlock(BlockState blockState) { Integer combinedId = getLegacyCombined(blockState); - return combinedId == null ? null : new int[]{combinedId >> 4, combinedId & 0xF}; + return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF }; + } + + public final static LegacyMapper getInstance() { + return INSTANCE; } @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) From 1e0e29b1c323cb3170fa1ca8895edc562e8840c6 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 11 Dec 2019 23:39:46 +0100 Subject: [PATCH 10/10] Update gradle.yml --- .github/workflows/gradle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 0a5a8d23f..cb41e9c99 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -5,10 +5,12 @@ on: branches: - master - merge + - 1.15 pull_request: branches: - master - merge + - 1.15 jobs: test: