Skip to content
Permalink
Browse files

Merge master

  • Loading branch information
octylFractal committed Dec 9, 2019
2 parents 0898ada + 7831eed commit 05db2046797cad060650181772793a69a2296e85
Showing with 4,766 additions and 4,508 deletions.
  1. +5 −1 .gitignore
  2. +22 −1 buildSrc/build.gradle.kts
  3. +1 −0 buildSrc/src/main/kotlin/PlatformConfig.kt
  4. +12 −1 buildSrc/src/main/kotlin/Versions.kt
  5. +4 −0 config/checkstyle/import-control.xml
  6. +3 −0 gradle.properties
  7. +1 −1 gradle/wrapper/gradle-wrapper.properties
  8. +2 −2 gradlew
  9. +2 −0 worldedit-bukkit/build.gradle.kts
  10. +25 −8 worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java
  11. +34 −24 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java
  12. +14 −6 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java
  13. +5 −3 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java
  14. +9 −1 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java
  15. +10 −2 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java
  16. +25 −3 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java
  17. +9 −15 .../NumberToken.java → worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWatchdog.java
  18. +32 −15 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
  19. +17 −0 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java
  20. BIN worldedit-bukkit/src/main/resources/worldedit-adapters.jar
  21. +9 −1 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java
  22. +3 −2 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java
  23. +65 −0 worldedit-core/build.gradle.kts
  24. +33 −21 worldedit-core/doctools/src/main/kotlin/com/sk89q/worldedit/internal/util/DocumentationPrinter.kt
  25. +70 −0 worldedit-core/doctools/src/main/kotlin/com/sk89q/worldedit/internal/util/RstWorldEditText.kt
  26. +236 −0 worldedit-core/src/main/antlr/com/sk89q/worldedit/antlr/Expression.g4
  27. +99 −40 worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
  28. +12 −0 worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java
  29. +27 −15 worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java
  30. +23 −10 worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java
  31. +5 −6 worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java
  32. +21 −12 worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java
  33. +25 −10 worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java
  34. +5 −4 worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java
  35. +33 −26 worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java
  36. +8 −5 worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java
  37. +60 −25 worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java
  38. +13 −11 worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java
  39. +9 −7 worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java
  40. +15 −13 worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java
  41. +6 −7 worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java
  42. +46 −35 worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java
  43. +14 −13 worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
  44. +4 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java
  45. +85 −65 worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
  46. +31 −27 worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java
  47. +15 −14 worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java
  48. +7 −5 worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java
  49. +116 −41 worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java
  50. +11 −10 worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java
  51. +39 −29 worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
  52. +34 −24 worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java
  53. +3 −0 worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java
  54. +3 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java
  55. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java
  56. +11 −5 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java
  57. +3 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java
  58. +3 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
  59. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java
  60. +4 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java
  61. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java
  62. +43 −26 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java
  63. +3 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/NavigationWand.java
  64. +4 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java
  65. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java
  66. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java
  67. +3 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java
  68. +8 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java
  69. +12 −0 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/FutureProgressListener.java
  70. +24 −0 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/HookMode.java
  71. +8 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/MessageTimerTask.java
  72. +11 −10 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java
  73. +7 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/util/WorldEditAsyncCommandBuilder.java
  74. +3 −5 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java
  75. +43 −0 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java
  76. +9 −0 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java
  77. +17 −25 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java
  78. +0 −4 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java
  79. +11 −4 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java
  80. +4 −15 .../sk89q/worldedit/{internal/expression/lexer/tokens/Token.java → extension/platform/Watchdog.java}
  81. +0 −4 worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java
  82. +33 −0 worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java
  83. +0 −4 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java
  84. +95 −0 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/WatchdogTickingExtent.java
  85. +9 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java
  86. +7 −10 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java
  87. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java
  88. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java
  89. +0 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java
  90. +5 −3 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/DelegateOperation.java
  91. +14 −19 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java
  92. +35 −1 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/Operation.java
  93. +5 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java
  94. +0 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java
  95. +16 −10 worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java
  96. +10 −3 worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java
  97. +10 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java
  98. +0 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java
  99. +10 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java
  100. +14 −5 worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java
  101. +118 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java
  102. +5 −4 ...dedit-core/src/main/java/com/sk89q/worldedit/internal/expression/{runtime → }/BreakException.java
  103. +625 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/EvaluatingVisitor.java
  104. +1 −1 ...-core/src/main/java/com/sk89q/worldedit/internal/expression/{runtime → }/EvaluationException.java
  105. +70 −80 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java
  106. +1 −1 ...ore/src/main/java/com/sk89q/worldedit/internal/expression/{runtime → }/ExpressionEnvironment.java
  107. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionException.java
  108. +149 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionHelper.java
  109. +1 −1 ...rc/main/java/com/sk89q/worldedit/internal/expression/{runtime → }/ExpressionTimeoutException.java
  110. +70 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionValidator.java
  111. +337 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Functions.java
  112. +7 −20 ...sk89q/worldedit/internal/expression/{lexer/tokens/IdentifierToken.java → LexerErrorListener.java}
  113. +1 −3 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/{lexer → }/LexerException.java
  114. +69 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/LocalSlot.java
  115. +7 −20 .../sk89q/worldedit/internal/expression/{lexer/tokens/OperatorToken.java → ParserErrorListener.java}
  116. +1 −3 ...dedit-core/src/main/java/com/sk89q/worldedit/internal/expression/{parser → }/ParserException.java
  117. +64 −0 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/SlotTable.java
  118. +0 −240 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/lexer/Lexer.java
  119. +0 −464 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/parser/Parser.java
  120. +0 −352 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java
  121. +0 −43 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/parser/PseudoToken.java
  122. +0 −50 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnaryOperator.java
  123. +0 −80 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnboundVariable.java
  124. +0 −50 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Break.java
  125. +0 −93 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Conditional.java
  126. +0 −49 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Constant.java
  127. +0 −107 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java
  128. +0 −123 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java
  129. +0 −487 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java
  130. +0 −38 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValue.java
  131. +0 −77 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValueFunction.java
  132. +0 −54 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Node.java
  133. +0 −228 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java
  134. +0 −37 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/RValue.java
  135. +0 −60 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Return.java
  136. +0 −41 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ReturnException.java
  137. +0 −109 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Sequence.java
  138. +0 −104 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java
  139. +0 −206 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java
  140. +0 −67 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Variable.java
  141. +0 −133 worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java
  142. +8 −0 worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
  143. +29 −11 worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java
  144. +9 −7 ...dedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java
  145. +21 −10 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java
  146. +15 −7 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java
  147. +25 −8 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java
  148. +12 −2 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java
  149. +11 −4 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java
  150. +8 −2 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java
  151. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
  152. +5 −4 worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java
  153. +6 −0 worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java
  154. +14 −1 worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java
  155. +1 −0 worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java
  156. +2 −0 worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java
  157. +18 −18 ...dapter.java → worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java
  158. +1 −0 worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java
  159. +5 −7 worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java
  160. +10 −1 worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java
  161. +60 −0 worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/TextUtils.java
  162. +18 −7 worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java
  163. +24 −0 worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java
  164. +160 −0 worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java
  165. +26 −16 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java
  166. +330 −0 worldedit-core/src/main/resources/lang/strings.json
  167. +100 −0 worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/BaseExpressionTest.java
  168. +61 −124 worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java
  169. +171 −0 worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java
  170. +1 −1 worldedit-core/src/test/resources/junit-platform.properties
  171. +24 −34 worldedit-fabric/build.gradle.kts
  172. +12 −0 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlatform.java
  173. +9 −1 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java
  174. +31 −0 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerEntity.java
  175. +16 −15 ....java → worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinMinecraftServer.java
  176. +5 −2 worldedit-fabric/src/main/resources/fabric.mod.json
  177. +4 −2 worldedit-fabric/src/main/resources/worldedit.mixins.json
  178. +6 −2 worldedit-forge/build.gradle.kts
  179. +10 −0 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java
  180. +9 −1 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java
  181. +10 −16 ...ns/KeywordToken.java → worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWatchdog.java
  182. +2 −0 worldedit-forge/src/main/resources/META-INF/accesstransformer.cfg
  183. +3 −3 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CommandAdapter.java
  184. +9 −1 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java
  185. +8 −1 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java
  186. +5 −1 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeTextAdapter.java
  187. +1 −0 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java
@@ -16,4 +16,8 @@ out
run

/dependency-reduced-pom.xml
*-private.sh
*-private.sh

# i18n
worldedit-core/src/main/resources/lang/*
!worldedit-core/src/main/resources/lang/strings.json
@@ -1,3 +1,5 @@
import java.util.Properties

plugins {
`kotlin-dsl`
kotlin("jvm") version embeddedKotlinVersion
@@ -10,6 +12,14 @@ repositories {
name = "Forge Maven"
url = uri("https://files.minecraftforge.net/maven")
}
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
maven {
name = "sponge"
url = uri("https://repo.spongepowered.org/maven")
}
}

configurations.all {
@@ -23,6 +33,14 @@ configurations.all {
}
}

val properties = Properties().also { props ->
project.projectDir.resolveSibling("gradle.properties").bufferedReader().use {
props.load(it)
}
}
val loomVersion: String = properties.getProperty("loom.version")
val mixinVersion: String = properties.getProperty("mixin.version")

dependencies {
implementation(gradleApi())
implementation("gradle.plugin.net.minecrell:licenser:0.4.1")
@@ -32,5 +50,8 @@ dependencies {
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0")
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.141")
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")
}
@@ -110,6 +110,7 @@ fun Project.applyShadowConfiguration() {
exclude("GradleStart**")
exclude(".cache")
exclude("LICENSE*")
exclude("META-INF/maven/**")
minimize()
}
}
@@ -1,8 +1,19 @@
import org.gradle.api.Project

object Versions {
const val TEXT = "3.0.1"
const val TEXT_EXTRAS = "3.0.2"
const val PISTON = "0.4.3"
const val PISTON = "0.5.2"
const val AUTO_VALUE = "1.6.5"
const val JUNIT = "5.5.0"
const val MOCKITO = "3.0.0"
}

// Properties that need a project reference to resolve:
class ProjectVersions(project: Project) {
val loom = project.rootProject.property("loom.version")
val mixin = project.rootProject.property("mixin.version")
}

val Project.versions
get() = ProjectVersions(this)
@@ -42,6 +42,10 @@
<allow pkg="com.google.auto"/>
<allow pkg="it.unimi.dsi.fastutil"/>

<subpackage name="internal.expression">
<allow pkg="org.antlr.v4"/>
</subpackage>

<subpackage name="bukkit">
<allow pkg="org.bukkit"/>
<allow pkg="org.bstats.bukkit"/>
@@ -2,3 +2,6 @@ group=com.sk89q.worldedit
version=7.1.0-SNAPSHOT

org.gradle.jvmargs=-Xmx1G

loom.version=0.2.5-20190906.190953-30
mixin.version=0.7.11.38
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
@@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -54,9 +54,11 @@ tasks.named<ShadowJar>("shadowJar") {
dependencies {
relocate("org.slf4j", "com.sk89q.worldedit.slf4j")
relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge")
relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4")
include(dependency(":worldedit-core"))
include(dependency("org.slf4j:slf4j-api"))
include(dependency("org.apache.logging.log4j:log4j-slf4j-impl"))
include(dependency("org.antlr:antlr4-runtime"))
relocate("org.bstats", "com.sk89q.worldedit.bukkit.bstats") {
include(dependency("org.bstats:bstats-bukkit:1.5"))
}
@@ -21,8 +21,10 @@

import com.sk89q.util.ReflectionUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandMap;
import org.bukkit.command.PluginIdentifiableCommand;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.plugin.Plugin;

@@ -40,6 +42,7 @@

protected final Plugin plugin;
protected final CommandExecutor executor;
private CommandMap serverCommandMap;
private CommandMap fallbackCommands;

public CommandRegistration(Plugin plugin) {
@@ -51,6 +54,15 @@ public CommandRegistration(Plugin plugin, CommandExecutor executor) {
this.executor = executor;
}

public Plugin getCommandOwner(String label) {
if (serverCommandMap == null) return null;
Command command = serverCommandMap.getCommand(label);
if (command instanceof PluginIdentifiableCommand) {
return ((PluginIdentifiableCommand) command).getPlugin();
}
return null;
}

public boolean register(List<CommandInfo> registered) {
CommandMap commandMap = getCommandMap();
if (registered == null || commandMap == null) {
@@ -66,16 +78,21 @@ public boolean register(List<CommandInfo> registered) {
}

public CommandMap getCommandMap() {
if (serverCommandMap != null) {
return serverCommandMap;
}
if (fallbackCommands != null) {
return fallbackCommands;
}

CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
if (commandMap == null) {
if (fallbackCommands != null) {
commandMap = fallbackCommands;
} else {
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
": Could not retrieve server CommandMap, using fallback instead!");
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin);
}
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
": Could not retrieve server CommandMap, using fallback instead!");
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin);
} else {
serverCommandMap = commandMap;
}
return commandMap;
}
@@ -21,14 +21,14 @@

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Function;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location;
@@ -45,13 +45,16 @@
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -349,18 +352,19 @@ public static EntityType adapt(org.bukkit.entity.EntityType entityType) {
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10));
}

private static EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
private static EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);

/**
* Converts a Material to a BlockType
*
* @param material The material
* @return The blocktype
*/
@Nullable
public static BlockType asBlockType(Material material) {
checkNotNull(material);
if (!material.isBlock()) {
throw new IllegalArgumentException(material.getKey().toString() + " is not a block!");
}
return BlockTypes.get(material.getKey().toString());
return materialBlockTypeCache.computeIfAbsent(material, input -> BlockTypes.get(material.getKey().toString()));
}

/**
@@ -369,15 +373,14 @@ public static BlockType asBlockType(Material material) {
* @param material The material
* @return The itemtype
*/
@Nullable
public static ItemType asItemType(Material material) {
checkNotNull(material);
if (!material.isItem()) {
throw new IllegalArgumentException(material.getKey().toString() + " is not an item!");
}
return ItemTypes.get(material.getKey().toString());
return materialItemTypeCache.computeIfAbsent(material, input -> ItemTypes.get(material.getKey().toString()));
}

private static Map<String, BlockState> blockStateCache = new HashMap<>();
private static Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>();
private static Map<String, BlockState> blockStateStringCache = new HashMap<>();

/**
* Create a WorldEdit BlockState from a Bukkit BlockData
@@ -387,21 +390,32 @@ public static ItemType asItemType(Material material) {
*/
public static BlockState adapt(BlockData blockData) {
checkNotNull(blockData);
return blockStateCache.computeIfAbsent(blockData.getAsString(), new Function<String, BlockState>() {
@Nullable
@Override
public BlockState apply(@Nullable String input) {

if (WorldEditPlugin.getInstance().getBukkitImplAdapter() == null) {
return blockStateStringCache.computeIfAbsent(blockData.getAsString(), input -> {
try {
return WorldEdit.getInstance().getBlockFactory().parseFromInput(input, TO_BLOCK_CONTEXT).toImmutableState();
} catch (InputParseException e) {
e.printStackTrace();
return null;
}
}
});
});
} else {
return blockStateCache.computeIfAbsent(
WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBlockStateId(blockData).orElseGet(
() -> blockData.getAsString().hashCode()
), input -> {
try {
return WorldEdit.getInstance().getBlockFactory().parseFromInput(blockData.getAsString(), TO_BLOCK_CONTEXT).toImmutableState();
} catch (InputParseException e) {
e.printStackTrace();
return null;
}
});
}
}

private static Map<String, BlockData> blockDataCache = new HashMap<>();
private static Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();

/**
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
@@ -411,13 +425,9 @@ public BlockState apply(@Nullable String input) {
*/
public static <B extends BlockStateHolder<B>> BlockData adapt(B block) {
checkNotNull(block);
return blockDataCache.computeIfAbsent(block.getAsString(), new Function<String, BlockData>() {
@Nullable
@Override
public BlockData apply(@Nullable String input) {
return Bukkit.createBlockData(block.getAsString());
}
}).clone();
// Should never not have an ID for this BlockState.
int cacheKey = BlockStateIdAccess.getBlockStateId(block.toImmutableState()).orElseGet(block::hashCode);
return blockDataCache.computeIfAbsent(cacheKey, input -> Bukkit.createBlockData(block.getAsString())).clone();
}

/**

0 comments on commit 05db204

Please sign in to comment.
You can’t perform that action at this time.