Гайд Как зафиксить срк rogalik

Начинающий
Статус
Онлайн
Регистрация
6 Дек 2023
Сообщения
150
Реакции[?]
0
Поинты[?]
0
всем ку увидел что типы не могут зафиксить срк рогалика так что держите
1725764963364.pngесли у вас такая ошибка то зайдите в класс DragStorage путь ru.rogalik.storages.draggs и заменяете класс DragStorage на мой код первая тема в гайдах не судите строго
Java:
package ru.rogalik.storages.draggs

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import ru.rogalik.Rouge
import ru.rogalik.api.Storeable
import ru.rogalik.functions.api.Function
import ru.rogalik.utils.client.VirtualFile
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.stream.Collectors

class DragStorage : Storeable<VirtualFile>(Rouge.directory.createFile("drags.json")) {
    val draggs: MutableList<Dragging> = ArrayList()
    val gson: Gson = GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();

    fun empty(): Boolean = draggs.isEmpty()
    fun has(name: String): Boolean = draggs.any { it.name.equals(name, ignoreCase = true) }
    fun add(module: Function, name: String, x: Float, y: Float): Dragging {
        val cached = draggs.find { it.name.equals(name, ignoreCase = true) } ?: Dragging(module, name, x, y).apply { this@DragStorage.draggs.add(this) }
        save()
        return cached
    }

    fun load() {
        BufferedReader(InputStreamReader(this.path.streamIn())).use { reader ->
            reader.lines().forEach { line ->
                try {
                    val drag = gson.fromJson<Dragging>(line, Dragging::class.java)
                    if (drag != null) {
                        val cached = draggs.find { it.name == drag.name }
                        if (cached != null) {
                            cached.x = drag.x
                            cached.y = drag.y
                        } else {
                            draggs.add(drag)
                        }
                    }
                } catch (e: Exception) {
                    println("Error deserializing line: $line")
                    e.printStackTrace()
                }
            }
        }
    }


    fun save() = this.path.streamOut()
        .apply { this.write(gson.toJson(draggs).toByteArray()) }
        .close()
}
 
Начинающий
Статус
Оффлайн
Регистрация
12 Июн 2024
Сообщения
320
Реакции[?]
1
Поинты[?]
1K
всем ку увидел что типы не могут зафиксить срк рогалика так что держите
Посмотреть вложение 285164если у вас такая ошибка то зайдите в класс DragStorage путь ru.rogalik.storages.draggs и заменяете класс DragStorage на мой код первая тема в гайдах не судите строго
Java:
package ru.rogalik.storages.draggs

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import ru.rogalik.Rouge
import ru.rogalik.api.Storeable
import ru.rogalik.functions.api.Function
import ru.rogalik.utils.client.VirtualFile
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.stream.Collectors

class DragStorage : Storeable<VirtualFile>(Rouge.directory.createFile("drags.json")) {
    val draggs: MutableList<Dragging> = ArrayList()
    val gson: Gson = GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();

    fun empty(): Boolean = draggs.isEmpty()
    fun has(name: String): Boolean = draggs.any { it.name.equals(name, ignoreCase = true) }
    fun add(module: Function, name: String, x: Float, y: Float): Dragging {
        val cached = draggs.find { it.name.equals(name, ignoreCase = true) } ?: Dragging(module, name, x, y).apply { this@DragStorage.draggs.add(this) }
        save()
        return cached
    }

    fun load() {
        BufferedReader(InputStreamReader(this.path.streamIn())).use { reader ->
            reader.lines().forEach { line ->
                try {
                    val drag = gson.fromJson<Dragging>(line, Dragging::class.java)
                    if (drag != null) {
                        val cached = draggs.find { it.name == drag.name }
                        if (cached != null) {
                            cached.x = drag.x
                            cached.y = drag.y
                        } else {
                            draggs.add(drag)
                        }
                    }
                } catch (e: Exception) {
                    println("Error deserializing line: $line")
                    e.printStackTrace()
                }
            }
        }
    }


    fun save() = this.path.streamOut()
        .apply { this.write(gson.toJson(draggs).toByteArray()) }
        .close()
}
а либки как закинуть скажешь?
а либки как закинуть скажешь?
я их закинул но все равно каких то нет
 
Начинающий
Статус
Оффлайн
Регистрация
27 Июн 2024
Сообщения
47
Реакции[?]
0
Поинты[?]
0
Просто скажи куда либки кидать и всё
dammnm
всем ку увидел что типы не могут зафиксить срк рогалика так что держите
Посмотреть вложение 285164если у вас такая ошибка то зайдите в класс DragStorage путь ru.rogalik.storages.draggs и заменяете класс DragStorage на мой код первая тема в гайдах не судите строго
Java:
package ru.rogalik.storages.draggs

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import ru.rogalik.Rouge
import ru.rogalik.api.Storeable
import ru.rogalik.functions.api.Function
import ru.rogalik.utils.client.VirtualFile
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.stream.Collectors

class DragStorage : Storeable<VirtualFile>(Rouge.directory.createFile("drags.json")) {
    val draggs: MutableList<Dragging> = ArrayList()
    val gson: Gson = GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();

    fun empty(): Boolean = draggs.isEmpty()
    fun has(name: String): Boolean = draggs.any { it.name.equals(name, ignoreCase = true) }
    fun add(module: Function, name: String, x: Float, y: Float): Dragging {
        val cached = draggs.find { it.name.equals(name, ignoreCase = true) } ?: Dragging(module, name, x, y).apply { this@DragStorage.draggs.add(this) }
        save()
        return cached
    }

    fun load() {
        BufferedReader(InputStreamReader(this.path.streamIn())).use { reader ->
            reader.lines().forEach { line ->
                try {
                    val drag = gson.fromJson<Dragging>(line, Dragging::class.java)
                    if (drag != null) {
                        val cached = draggs.find { it.name == drag.name }
                        if (cached != null) {
                            cached.x = drag.x
                            cached.y = drag.y
                        } else {
                            draggs.add(drag)
                        }
                    }
                } catch (e: Exception) {
                    println("Error deserializing line: $line")
                    e.printStackTrace()
                }
            }
        }
    }


    fun save() = this.path.streamOut()
        .apply { this.write(gson.toJson(draggs).toByteArray()) }
        .close()
}
damnn что с кодом
 
Последнее редактирование:
Сверху Снизу