Skip to content

Commit

Permalink
Fix doctools with platform refactor (#2410)
Browse files Browse the repository at this point in the history
* Fix doctools with platform refactor

* Use PREFER_OTHERS
  • Loading branch information
me4502 authored Oct 17, 2023
1 parent 7a18a44 commit eadbdeb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ package com.sk89q.worldedit.internal.util

import com.sk89q.worldedit.entity.Player
import com.sk89q.worldedit.extension.platform.AbstractPlatform
import com.sk89q.worldedit.extension.platform.Capability
import com.sk89q.worldedit.extension.platform.Preference
import com.sk89q.worldedit.world.World
import org.enginehub.piston.CommandManager
import java.nio.file.Files
import java.nio.file.Paths
import java.util.EnumMap
import java.util.Properties

class DocumentationPlatform : AbstractPlatform() {
Expand Down Expand Up @@ -55,11 +58,20 @@ class DocumentationPlatform : AbstractPlatform() {

override fun matchWorld(world: World?) = error("Documentation does not provide this")

override fun registerCommands(commandManager: CommandManager?) = error("Documentation does not provide this")
override fun registerCommands(commandManager: CommandManager?) {}

override fun setGameHooksEnabled(enabled: Boolean) = error("Documentation does not provide this")
override fun setGameHooksEnabled(enabled: Boolean) {}

override fun getCapabilities() = error("Documentation does not provide this")
override fun getCapabilities(): MutableMap<Capability, Preference> {
val capabilities: MutableMap<Capability, Preference> = EnumMap(Capability::class.java)
capabilities[Capability.CONFIGURATION] = Preference.PREFER_OTHERS
capabilities[Capability.WORLDEDIT_CUI] = Preference.PREFER_OTHERS
capabilities[Capability.GAME_HOOKS] = Preference.PREFER_OTHERS
capabilities[Capability.PERMISSIONS] = Preference.PREFER_OTHERS
capabilities[Capability.USER_COMMANDS] = Preference.PREFER_OTHERS
capabilities[Capability.WORLD_EDITING] = Preference.PREFER_OTHERS
return capabilities
}

override fun getSupportedSideEffects() = error("Documentation does not provide this")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import com.sk89q.worldedit.command.ToolCommands
import com.sk89q.worldedit.command.ToolUtilCommands
import com.sk89q.worldedit.command.UtilityCommands
import com.sk89q.worldedit.command.util.PermissionCondition
import com.sk89q.worldedit.event.platform.PlatformReadyEvent
import com.sk89q.worldedit.event.platform.PlatformsRegisteredEvent
import com.sk89q.worldedit.internal.command.CommandUtil
import com.sk89q.worldedit.util.formatting.text.TextComponent
import org.enginehub.piston.Command
Expand Down Expand Up @@ -337,7 +339,10 @@ Other Permissions
@JvmStatic
fun main(args: Array<String>) {
try {
WorldEdit.getInstance().platformManager.register(DocumentationPlatform())
val plat = DocumentationPlatform()
WorldEdit.getInstance().platformManager.register(plat)
WorldEdit.getInstance().eventBus.post(PlatformReadyEvent(plat))
WorldEdit.getInstance().eventBus.post(PlatformsRegisteredEvent())
val printer = DocumentationPrinter()

printer.writeAllCommands()
Expand Down

0 comments on commit eadbdeb

Please sign in to comment.