bump kutil, remove some todos, minimal cleanup

This commit is contained in:
Bixilon 2022-05-01 16:56:48 +02:00
parent 69d48f31ad
commit 199559bca7
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
29 changed files with 105 additions and 105 deletions

View File

@ -474,7 +474,7 @@
<dependency>
<groupId>de.bixilon</groupId>
<artifactId>kutil</artifactId>
<version>1.10.4</version>
<version>1.10.5</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -13,7 +13,7 @@
package de.bixilon.minosoft.config.key
enum class KeyAction {
enum class KeyActions {
// primitive ones
/**

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonInclude
import de.bixilon.minosoft.util.KUtil.synchronizedDeepCopy
class KeyBinding(
val action: Map<KeyAction, Set<KeyCodes>>,
val action: Map<KeyActions, Set<KeyCodes>>,
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var ignoreConsumer: Boolean = false,
) {
constructor(keyBinding: KeyBinding) : this(keyBinding.action.synchronizedDeepCopy()) // ToDo: Deep copy

View File

@ -18,7 +18,7 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
import de.bixilon.kutil.collections.map.LockMap
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
@ -96,8 +96,8 @@ class EntityHitboxRenderer(
renderWindow.inputHandler.registerKeyCallback(HITBOX_TOGGLE_KEY_COMBINATION,
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F3),
KeyAction.STICKY to setOf(KeyCodes.KEY_B),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F3),
KeyActions.STICKY to setOf(KeyCodes.KEY_B),
),
), defaultPressed = profile.enabled) {
profile.enabled = it

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.framebuffer.world.`fun`
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.registries.ResourceLocation
@ -36,8 +36,8 @@ class FunEffectManager(
renderWindow.inputHandler.registerKeyCallback("minosoft:switch_fun_settings".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyAction.PRESS to setOf(KeyCodes.KEY_J),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyActions.PRESS to setOf(KeyCodes.KEY_J),
),
)) {
effectUsed++

View File

@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2d
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.gui.rendering.gui.GUIElement
@ -66,7 +66,7 @@ class GUIManager(
renderWindow.inputHandler.registerKeyCallback("minosoft:back".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.RELEASE to setOf(KeyCodes.KEY_ESCAPE),
KeyActions.RELEASE to setOf(KeyCodes.KEY_ESCAPE),
),
ignoreConsumer = true,
)) { popOrPause() }

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.gui.gui.screen.container
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.container.Container
@ -30,7 +30,7 @@ object ContainerGUIManager {
private fun registerLocalContainerEvent(guiRenderer: GUIRenderer) {
guiRenderer.renderWindow.inputHandler.registerKeyCallback("minosoft:local_inventory".toResourceLocation(), KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_E),
KeyActions.PRESS to setOf(KeyCodes.KEY_E),
),
)) { guiRenderer.gui.open(LocalInventoryScreen) }
}

View File

@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.gui.hud
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.registries.ResourceLocation
@ -91,7 +91,7 @@ class HUDManager(
renderWindow.inputHandler.registerKeyCallback("minosoft:enable_hud".toResourceLocation(), KeyBinding(
mapOf(
KeyAction.STICKY to setOf(KeyCodes.KEY_F1),
KeyActions.STICKY to setOf(KeyCodes.KEY_F1),
),
), defaultPressed = enabled) { enabled = it }
}

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.gui.hud.elements.chat
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatchRendering
@ -90,7 +90,7 @@ class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer) {
renderWindow.inputHandler.registerKeyCallback("minosoft:open_chat".toResourceLocation(), KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_T),
KeyActions.PRESS to setOf(KeyCodes.KEY_T),
),
)) { guiRenderer.gui.open(ChatElement) }
}

View File

@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kotlinglm.vec4.Vec4i
import de.bixilon.kutil.math.simple.DoubleMath.rounded10
import de.bixilon.kutil.unit.UnitFormatter.formatBytes
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.direction.Directions
@ -311,7 +311,7 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
override val DEFAULT_ENABLED: Boolean = false
override val ENABLE_KEY_BINDING: KeyBinding = KeyBinding(
mapOf(
KeyAction.STICKY to setOf(KeyCodes.KEY_F3),
KeyActions.STICKY to setOf(KeyCodes.KEY_F3),
),
)

View File

@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.registries.ResourceLocation
@ -256,7 +256,7 @@ class TabListElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedE
override val ENABLE_KEY_BINDING_NAME: ResourceLocation = "minosoft:enable_tab_list".toResourceLocation()
override val ENABLE_KEY_BINDING: KeyBinding = KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_TAB),
KeyActions.CHANGE to setOf(KeyCodes.KEY_TAB),
),
)

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.input
import de.bixilon.kotlinglm.GLM
import de.bixilon.kotlinglm.vec2.Vec2d
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.entities.EntityRotation
@ -46,52 +46,52 @@ class CameraInput(
renderWindow.inputHandler.registerCheckCallback(
MOVE_SPRINT_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_LEFT_CONTROL),
KeyActions.CHANGE to setOf(KeyCodes.KEY_LEFT_CONTROL),
),
),
MOVE_FORWARDS_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_W),
KeyActions.CHANGE to setOf(KeyCodes.KEY_W),
),
),
MOVE_BACKWARDS_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_S),
KeyActions.CHANGE to setOf(KeyCodes.KEY_S),
),
),
MOVE_LEFT_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_A),
KeyActions.CHANGE to setOf(KeyCodes.KEY_A),
),
),
MOVE_RIGHT_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_D),
KeyActions.CHANGE to setOf(KeyCodes.KEY_D),
),
),
FLY_UP_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_SPACE),
KeyActions.CHANGE to setOf(KeyCodes.KEY_SPACE),
),
),
FLY_DOWN_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_LEFT_SHIFT),
KeyActions.CHANGE to setOf(KeyCodes.KEY_LEFT_SHIFT),
),
),
JUMP_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_SPACE),
KeyActions.CHANGE to setOf(KeyCodes.KEY_SPACE),
),
),
SNEAK_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_LEFT_SHIFT),
KeyActions.CHANGE to setOf(KeyCodes.KEY_LEFT_SHIFT),
),
),
TOGGLE_FLY_KEYBINDING to KeyBinding(
mapOf(
KeyAction.DOUBLE_PRESS to setOf(KeyCodes.KEY_SPACE),
KeyActions.DOUBLE_PRESS to setOf(KeyCodes.KEY_SPACE),
),
),
)
@ -99,7 +99,7 @@ class CameraInput(
renderWindow.inputHandler.registerKeyCallback(ZOOM_KEYBINDING, KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.KEY_C),
KeyActions.CHANGE to setOf(KeyCodes.KEY_C),
),
)) { matrixHandler.zoom = if (it) 2.0f else 0.0f }
}

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.rendering.input.interaction
import de.bixilon.kutil.rate.RateLimiter
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.abilities.Gamemodes
@ -45,7 +45,7 @@ class AttackInteractionHandler(
fun init() {
renderWindow.inputHandler.registerKeyCallback(ATTACK_ENTITY_KEYBINDING, KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.MOUSE_BUTTON_LEFT),
KeyActions.PRESS to setOf(KeyCodes.MOUSE_BUTTON_LEFT),
),
), false) { tryAttack() }
}

View File

@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.pow
import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.abilities.Gamemodes
@ -250,7 +250,7 @@ class BreakInteractionHandler(
fun init() {
renderWindow.inputHandler.registerCheckCallback(DESTROY_BLOCK_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.MOUSE_BUTTON_LEFT),
KeyActions.CHANGE to setOf(KeyCodes.MOUSE_BUTTON_LEFT),
),
))

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.input.interaction
import de.bixilon.kutil.rate.RateLimiter
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.gui.rendering.RenderWindow
@ -33,13 +33,13 @@ class DropInteractionManager(
// ToDo: Does this swing the arm?
renderWindow.inputHandler.registerKeyCallback(DROP_ITEM_STACK_KEYBINDING, KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_Q),
KeyAction.MODIFIER to setOf(KeyCodes.KEY_LEFT_CONTROL)
KeyActions.PRESS to setOf(KeyCodes.KEY_Q),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_LEFT_CONTROL)
),
)) { dropItem(true) }
renderWindow.inputHandler.registerKeyCallback(DROP_ITEM_KEYBINDING, KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_Q),
KeyActions.PRESS to setOf(KeyCodes.KEY_Q),
),
)) { dropItem(false) }
}

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.input.interaction
import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
import de.bixilon.kutil.rate.RateLimiter
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.abilities.Gamemodes
@ -78,7 +78,7 @@ class HotbarInteractionHandler(
for (i in 1..PlayerInventory.HOTBAR_SLOTS) {
renderWindow.inputHandler.registerKeyCallback("minosoft:hotbar_slot_$i".toResourceLocation(), KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_CODE_MAP["$i"]!!),
KeyActions.PRESS to setOf(KeyCodes.KEY_CODE_MAP["$i"]!!),
),
)) { selectSlot(i - 1) }
}
@ -108,7 +108,7 @@ class HotbarInteractionHandler(
renderWindow.inputHandler.registerKeyCallback("minosoft:swap_items".toResourceLocation(), KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_F),
KeyActions.PRESS to setOf(KeyCodes.KEY_F),
),
)) { swapItems() }
}

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.input.interaction
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.abilities.Gamemodes
@ -52,7 +52,7 @@ class InteractInteractionHandler(
fun init() {
renderWindow.inputHandler.registerCheckCallback(USE_ITEM_KEYBINDING to KeyBinding(
mapOf(
KeyAction.CHANGE to setOf(KeyCodes.MOUSE_BUTTON_RIGHT),
KeyActions.CHANGE to setOf(KeyCodes.MOUSE_BUTTON_RIGHT),
),
))
}

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.rendering.input.interaction
import de.bixilon.kutil.rate.RateLimiter
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.container.InventorySlots
@ -38,7 +38,7 @@ class ItemPickInteractionHandler(
fun init() {
renderWindow.inputHandler.registerKeyCallback("minosoft:pick_item".toResourceLocation(), KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.MOUSE_BUTTON_MIDDLE),
KeyActions.PRESS to setOf(KeyCodes.MOUSE_BUTTON_MIDDLE),
),
)) {
pickItem(true) // ToDo: Combination for not copying nbt

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.rendering.input.interaction
import de.bixilon.kutil.rate.RateLimiter
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.abilities.Gamemodes
@ -34,7 +34,7 @@ class SpectateInteractionManager(
fun init() {
renderWindow.inputHandler.registerKeyCallback(STOP_SPECTATING, KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_LEFT_SHIFT),
KeyActions.PRESS to setOf(KeyCodes.KEY_LEFT_SHIFT),
),
)) { spectate(null) }

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.rendering.input.key
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.gui.rendering.RenderWindow
@ -32,8 +32,8 @@ object DefaultKeyCombinations {
inputHandler.registerKeyCallback("minosoft:enable_debug_polygon".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyAction.STICKY to setOf(KeyCodes.KEY_P),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyActions.STICKY to setOf(KeyCodes.KEY_P),
),
)) {
val nextMode = it.decide(PolygonModes.LINE, PolygonModes.FILL)
@ -44,7 +44,7 @@ object DefaultKeyCombinations {
inputHandler.registerKeyCallback("minosoft:take_screenshot".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_F2),
KeyActions.PRESS to setOf(KeyCodes.KEY_F2),
),
ignoreConsumer = true,
)) { renderWindow.screenshotTaker.takeScreenshot() }
@ -52,8 +52,8 @@ object DefaultKeyCombinations {
inputHandler.registerKeyCallback("minosoft:pause_incoming_packets".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyAction.STICKY to setOf(KeyCodes.KEY_I),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyActions.STICKY to setOf(KeyCodes.KEY_I),
),
ignoreConsumer = true,
)) {
@ -64,8 +64,8 @@ object DefaultKeyCombinations {
inputHandler.registerKeyCallback("minosoft:pause_outgoing_packets".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyAction.STICKY to setOf(KeyCodes.KEY_O),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyActions.STICKY to setOf(KeyCodes.KEY_O),
),
ignoreConsumer = true,
)) {
@ -76,7 +76,7 @@ object DefaultKeyCombinations {
inputHandler.registerKeyCallback("minosoft:toggle_fullscreen".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.PRESS to setOf(KeyCodes.KEY_F11),
KeyActions.PRESS to setOf(KeyCodes.KEY_F11),
),
ignoreConsumer = true,
)) {

View File

@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2d
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.delegate.watcher.entry.MapProfileDelegateWatcher.Companion.profileWatchMap
@ -78,8 +78,8 @@ class RenderWindowInputHandler(
registerKeyCallback("minosoft:debug_change_cursor_mode".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyAction.PRESS to setOf(KeyCodes.KEY_M),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyActions.PRESS to setOf(KeyCodes.KEY_M),
),
ignoreConsumer = true,
), defaultPressed = StaticConfiguration.DEBUG_MODE) {
@ -139,10 +139,10 @@ class RenderWindowInputHandler(
}
// ToDo
if (pair.keyBinding.action[KeyAction.DOUBLE_PRESS] != null) {
if (pair.keyBinding.action[KeyActions.DOUBLE_PRESS] != null) {
continue
}
if (pair.keyBinding.action[KeyAction.STICKY] != null) {
if (pair.keyBinding.action[KeyActions.STICKY] != null) {
continue
}
@ -182,7 +182,7 @@ class RenderWindowInputHandler(
var thisIsChange = true
var saveDown = true
pair.keyBinding.action[KeyAction.PRESS]?.let {
pair.keyBinding.action[KeyActions.PRESS]?.let {
if (!keyDown) {
thisIsChange = false
}
@ -194,7 +194,7 @@ class RenderWindowInputHandler(
checksRun++
}
pair.keyBinding.action[KeyAction.RELEASE]?.let {
pair.keyBinding.action[KeyActions.RELEASE]?.let {
if (keyDown) {
thisIsChange = false
}
@ -206,21 +206,21 @@ class RenderWindowInputHandler(
checksRun++
}
pair.keyBinding.action[KeyAction.CHANGE]?.let {
pair.keyBinding.action[KeyActions.CHANGE]?.let {
if (!it.contains(keyCode)) {
thisIsChange = false
}
checksRun++
}
pair.keyBinding.action[KeyAction.MODIFIER]?.let {
pair.keyBinding.action[KeyActions.MODIFIER]?.let {
if (!keysDown.containsAll(it)) {
thisIsChange = false
}
checksRun++
}
pair.keyBinding.action[KeyAction.STICKY]?.let {
pair.keyBinding.action[KeyActions.STICKY]?.let {
checksRun++
if (!it.contains(keyCode)) {
thisIsChange = false
@ -233,7 +233,7 @@ class RenderWindowInputHandler(
thisKeyBindingDown = !keyBindingsDown.contains(resourceLocation)
}
pair.keyBinding.action[KeyAction.DOUBLE_PRESS]?.let {
pair.keyBinding.action[KeyActions.DOUBLE_PRESS]?.let {
checksRun++
if (!keyDown) {
thisIsChange = false
@ -310,7 +310,7 @@ class RenderWindowInputHandler(
val callbackPair = keyBindingCallbacks.getOrPut(resourceLocation) { KeyBindingCallbackPair(keyBinding, defaultKeyBinding, defaultPressed) }
callbackPair.callback += callback
if (keyBinding.action.containsKey(KeyAction.STICKY) && defaultPressed) {
if (keyBinding.action.containsKey(KeyActions.STICKY) && defaultPressed) {
keyBindingsDown += resourceLocation
}
}

View File

@ -27,7 +27,7 @@ import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
@ -251,8 +251,8 @@ class WorldRenderer(
renderWindow.inputHandler.registerKeyCallback("minosoft:clear_chunk_cache".toResourceLocation(),
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F3),
KeyAction.PRESS to setOf(KeyCodes.KEY_A),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F3),
KeyActions.PRESS to setOf(KeyCodes.KEY_A),
),
)) { clearChunkCache() }

View File

@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.world.chunk
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.registries.ResourceLocation
@ -49,8 +49,8 @@ class ChunkBorderRenderer(
renderWindow.inputHandler.registerKeyCallback(CHUNK_BORDER_TOGGLE_KEY_COMBINATION,
KeyBinding(
mapOf(
KeyAction.MODIFIER to setOf(KeyCodes.KEY_F3),
KeyAction.STICKY to setOf(KeyCodes.KEY_G),
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F3),
KeyActions.STICKY to setOf(KeyCodes.KEY_G),
),
), defaultPressed = profile.chunkBorder.enabled) {
profile.chunkBorder.enabled = it

View File

@ -127,7 +127,6 @@ class PlayConnection(
network.state = ProtocolStates.LOGIN
} else {
wasConnected = true
//ToDo: Minosoft.CONNECTIONS.remove(connectionId)
if (CLI.getCurrentConnection() == this) {
CLI.setCurrentConnection(null)
Command.print("Disconnected from current connection!")

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.protocol.network.connection.status
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
import de.bixilon.kutil.concurrent.time.TimeWorker
import de.bixilon.kutil.concurrent.time.TimeWorkerTask
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
import de.bixilon.minosoft.data.registries.versions.Version
@ -57,6 +58,8 @@ class StatusConnection(
var state by watched(StatusConnectionStates.WAITING)
private var timeoutTask: TimeWorkerTask? = null
override var error: Throwable?
get() = super.error
@ -105,6 +108,14 @@ class StatusConnection(
}
}
}
this::state.observe(this) {
if (it == StatusConnectionStates.PING_DONE) {
val timeoutTask = timeoutTask ?: return@observe
timeoutTask.interrupt()
TimeWorker.removeTask(timeoutTask)
this.timeoutTask = null
}
}
}
@ -135,8 +146,7 @@ class StatusConnection(
state = StatusConnectionStates.RESOLVING
// timeout task
// ToDo: Cancel on success
TimeWorker.runIn(30000) {
timeoutTask = TimeWorker.runIn(30000) {
if (state == StatusConnectionStates.ERROR) {
return@runIn
}

View File

@ -63,16 +63,6 @@ public final class ProtocolDefinition {
public static final int BLOCKS_PER_SECTION = SECTION_WIDTH_X * SECTION_HEIGHT_Y * SECTION_WIDTH_X;
public static final int ITEM_STACK_MAX_SIZE = 64;
// public static final String MICROSOFT_ACCOUNT_APPLICATION_ID = "00000000402b5328"; // ToDo: Should we use our own application id?
public static final String MICROSOFT_ACCOUNT_APPLICATION_ID = "feb3836f-0333-4185-8eb9-4cbf0498f947"; // Minosoft 2 (microsoft-bixilon2)
public static final String MICROSOFT_ACCOUNT_OAUTH_FLOW_URL = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?client_id=" + MICROSOFT_ACCOUNT_APPLICATION_ID + "&scope=XboxLive.signin%20offline_access&response_type=code";
public static final String MICROSOFT_ACCOUNT_AUTH_TOKEN_URL = "https://login.live.com/oauth20_token.srf";
public static final String MICROSOFT_ACCOUNT_XBOX_LIVE_AUTHENTICATE_URL = "https://user.auth.xboxlive.com/user/authenticate";
public static final String MICROSOFT_ACCOUNT_XSTS_URL = "https://xsts.auth.xboxlive.com/xsts/authorize";
public static final String MICROSOFT_ACCOUNT_MINECRAFT_LOGIN_WITH_XBOX_URL = "https://api.minecraftservices.com/authentication/login_with_xbox";
public static final String MICROSOFT_ACCOUNT_GET_MOJANG_PROFILE_URL = "https://api.minecraftservices.com/minecraft/profile";
public static final char[] OBFUSCATED_CHARS = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~".toCharArray();
@ -83,9 +73,6 @@ public final class ProtocolDefinition {
public static final float VELOCITY_NETWORK_DIVIDER = 8000.0f;
public static final float GRAVITY = 32;
public static final boolean FAST_MOVEMENT = true;
public static final int SEA_LEVEL_HEIGHT = 62;
public static final float HEIGHT_SEA_LEVEL_MODIFIER = 0.00166667f;

View File

@ -41,7 +41,7 @@ class RecipeRegistry(
is ResourceLocation -> resourceLocationRecipeMap[any]
is String -> get(any.toResourceLocation())
is ResourceLocationAble -> get(any.resourceLocation)
else -> TODO()
else -> throw IllegalArgumentException("Can not get recipe from $any")
} ?: parent?.get(any)
}

View File

@ -15,7 +15,6 @@ package de.bixilon.minosoft.util.account
import de.bixilon.kutil.uuid.UUIDUtil.trim
import de.bixilon.minosoft.data.accounts.types.microsoft.MinecraftTokens
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import de.bixilon.minosoft.util.account.microsoft.minecraft.MinecraftAPIException
import de.bixilon.minosoft.util.account.microsoft.minecraft.MinecraftProfile
import de.bixilon.minosoft.util.http.HTTP2.getJson
@ -27,10 +26,11 @@ import de.bixilon.minosoft.util.logging.LogMessageType
import java.util.*
object AccountUtil {
private const val GET_PROFILE_URL = "https://api.minecraftservices.com/minecraft/profile"
private const val MOJANG_URL_JOIN = "https://sessionserver.mojang.com/session/minecraft/join"
fun fetchMinecraftProfile(token: MinecraftTokens): MinecraftProfile {
val response = ProtocolDefinition.MICROSOFT_ACCOUNT_GET_MOJANG_PROFILE_URL.getJson(mapOf(
val response = GET_PROFILE_URL.getJson(mapOf(
"Authorization" to "Bearer ${token.accessToken}",
))

View File

@ -21,7 +21,6 @@ import de.bixilon.minosoft.data.accounts.AccountStates
import de.bixilon.minosoft.data.accounts.types.microsoft.MicrosoftAccount
import de.bixilon.minosoft.data.accounts.types.microsoft.MicrosoftTokens
import de.bixilon.minosoft.data.player.properties.PlayerProperties
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import de.bixilon.minosoft.util.account.AccountUtil
import de.bixilon.minosoft.util.account.microsoft.code.MicrosoftDeviceCode
import de.bixilon.minosoft.util.account.microsoft.minecraft.MinecraftAPIException
@ -39,9 +38,14 @@ import de.bixilon.minosoft.util.logging.LogMessageType
import java.util.concurrent.TimeoutException
object MicrosoftOAuthUtils {
const val CLIENT_ID = "feb3836f-0333-4185-8eb9-4cbf0498f947" // Minosoft 2 (microsoft-bixilon2)
const val TENANT = "consumers"
const val DEVICE_CODE_URL = "https://login.microsoftonline.com/$TENANT/oauth2/v2.0/devicecode"
const val TOKEN_CHECK_URL = "https://login.microsoftonline.com/$TENANT/oauth2/v2.0/token"
const val XBOX_LIVE_AUTH_URL = "https://user.auth.xboxlive.com/user/authenticate"
const val XSTS_URL = "https://xsts.auth.xboxlive.com/xsts/authorize"
const val LOGIN_WITH_XBOX_URL = "https://api.minecraftservices.com/authentication/login_with_xbox"
const val MAX_CHECK_TIME = 900
fun obtainDeviceCodeAsync(
@ -80,7 +84,7 @@ object MicrosoftOAuthUtils {
fun obtainDeviceCode(): MicrosoftDeviceCode {
val response = mapOf(
"client_id" to ProtocolDefinition.MICROSOFT_ACCOUNT_APPLICATION_ID,
"client_id" to CLIENT_ID,
"scope" to "XboxLive.signin offline_access",
).postData(DEVICE_CODE_URL)
@ -94,7 +98,7 @@ object MicrosoftOAuthUtils {
fun checkDeviceCode(deviceCode: MicrosoftDeviceCode): AuthenticationResponse? {
val response = mapOf(
"grant_type" to "urn:ietf:params:oauth:grant-type:device_code",
"client_id" to ProtocolDefinition.MICROSOFT_ACCOUNT_APPLICATION_ID,
"client_id" to CLIENT_ID,
"device_code" to deviceCode.deviceCode,
).postData(TOKEN_CHECK_URL)
@ -111,7 +115,7 @@ object MicrosoftOAuthUtils {
fun refreshToken(token: MicrosoftTokens): AuthenticationResponse {
val response = mapOf(
"client_id" to ProtocolDefinition.MICROSOFT_ACCOUNT_APPLICATION_ID,
"client_id" to CLIENT_ID,
"grant_type" to "refresh_token",
"scope" to "XboxLive.signin offline_access",
"refresh_token" to token.refreshToken,
@ -165,7 +169,7 @@ object MicrosoftOAuthUtils {
),
"RelyingParty" to "http://auth.xboxlive.com",
"TokenType" to "JWT",
).postJson(ProtocolDefinition.MICROSOFT_ACCOUNT_XBOX_LIVE_AUTHENTICATE_URL)
).postJson(XBOX_LIVE_AUTH_URL)
if (response.statusCode != 200 || response.body == null) {
@ -183,7 +187,7 @@ object MicrosoftOAuthUtils {
),
"RelyingParty" to "rp://api.minecraftservices.com/",
"TokenType" to "JWT",
).postJson(ProtocolDefinition.MICROSOFT_ACCOUNT_XSTS_URL)
).postJson(XSTS_URL)
if (response.statusCode != 200) {
val error = Jackson.MAPPER.convertValue(response.body, XboxAPIError::class.java)
@ -204,7 +208,7 @@ object MicrosoftOAuthUtils {
val response = mapOf(
"identityToken" to "XBL3.0 x=${xBoxLiveToken.userHash};${xstsToken.token}",
"ensureLegacyEnabled" to true,
).postJson(ProtocolDefinition.MICROSOFT_ACCOUNT_MINECRAFT_LOGIN_WITH_XBOX_URL)
).postJson(LOGIN_WITH_XBOX_URL)
if (response.statusCode != 200) {
throw MinecraftAPIException(response)