1
0
Fork 0

feat: convert to spigot plugin

This commit is contained in:
ineanto 2025-09-13 15:59:24 +02:00
parent 7665ef9114
commit cad059a376
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
9 changed files with 72 additions and 25 deletions

View file

@ -1,5 +1,4 @@
- [ ] Système de bounties pour les nazes (objectifs à complèter) - [ ] Système de bounties pour les nazes (objectifs à complèter)
- [ ] Système de palier par équipe (qui en est où par rapport au dragon)
- [ ] Démarrage en forme de Title - [ ] Démarrage en forme de Title
- [ ] spread le spawn dans un rayon de 1000 blocks - [ ] spread le spawn dans un rayon de 1000 blocks
@ -11,4 +10,8 @@ balancer les coordonnées
```kotlin ```kotlin
val advancement = Advancement.Builder.advancement().save({}, "runnerdragon:test").toBukkit() val advancement = Advancement.Builder.advancement().save({}, "runnerdragon:test").toBukkit()
Player.getAdvancementProgress(advancement) Player.getAdvancementProgress(advancement)
// Localiser les structures proches
val locateNearestStructure =
player.world.locateNearestStructure(player.location, StructureType.STRONGHOLD, 300, false)
``` ```

View file

@ -20,12 +20,12 @@ dependencies {
paperweight.paperDevBundle("1.21.8-R0.1-SNAPSHOT") paperweight.paperDevBundle("1.21.8-R0.1-SNAPSHOT")
// Inventory UI // Inventory UI
compileOnly(libs.invui) implementation(libs.invui)
compileOnly(libs.invui.kotlin) implementation(libs.invui.kotlin)
// Resource Pack (unused) // WorldEdit
implementation(libs.glyphs.api) compileOnly("com.sk89q.worldedit:worldedit-core:7.3.16-SNAPSHOT")
implementation(libs.glyphs.resources) compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.16-SNAPSHOT")
implementation(libs.kotlin.stdlib) implementation(libs.kotlin.stdlib)
implementation(libs.commonsio) implementation(libs.commonsio)
@ -46,5 +46,9 @@ tasks {
runServer { runServer {
minecraftVersion("1.21.8") minecraftVersion("1.21.8")
downloadPlugins {
url("https://cdn.modrinth.com/data/1u6JkXh5/versions/Jk1z2u7n/worldedit-bukkit-7.3.16.jar")
}
} }
} }

View file

@ -20,6 +20,7 @@ import xyz.ineanto.dragon.event.end.BlockPlaceListener
import xyz.ineanto.dragon.event.end.FinalBlowListener import xyz.ineanto.dragon.event.end.FinalBlowListener
import xyz.ineanto.dragon.event.waiting.WaitingListener import xyz.ineanto.dragon.event.waiting.WaitingListener
import xyz.ineanto.dragon.player.PlayerManager import xyz.ineanto.dragon.player.PlayerManager
import xyz.ineanto.dragon.schematic.SchematicLoader
import xyz.ineanto.dragon.scoreboard.ScoreboardTeams import xyz.ineanto.dragon.scoreboard.ScoreboardTeams
import xyz.ineanto.dragon.tasks.GracePeriodTask import xyz.ineanto.dragon.tasks.GracePeriodTask
import xyz.ineanto.dragon.tasks.TimerTask import xyz.ineanto.dragon.tasks.TimerTask
@ -27,6 +28,7 @@ import xyz.ineanto.dragon.teams.Team
import xyz.ineanto.dragon.teams.TeamManager import xyz.ineanto.dragon.teams.TeamManager
import xyz.ineanto.dragon.world.WorldManager import xyz.ineanto.dragon.world.WorldManager
import xyz.xenondevs.invui.InvUI import xyz.xenondevs.invui.InvUI
import java.io.File
import java.time.Duration import java.time.Duration
import java.time.Instant import java.time.Instant
import java.util.* import java.util.*
@ -58,11 +60,13 @@ class RunnerDragon : JavaPlugin() {
var DEAD_COWS = 0 var DEAD_COWS = 0
var ELAPSED_TIME = 0 var ELAPSED_TIME = 0
var SPAWN_HEIGHT = 300 var SPAWN_HEIGHT = 150
var TEAM_LOCK = false var TEAM_LOCK = false
var NETHER_PORTAL_ENTERED = false var NETHER_PORTAL_ENTERED = false
var END_PORTAL_ENTERED = false var END_PORTAL_ENTERED = false
lateinit var LOBBY_SCHEMATIC: SchematicLoader
//............. //.............
// TASKS // TASKS
//............. //.............
@ -129,8 +133,8 @@ class RunnerDragon : JavaPlugin() {
DEAD_COWS = 0 DEAD_COWS = 0
logger.info("Génération du spawn...") logger.info("Génération du spawn...")
//LOBBY_SCHEMATIC = SchematicLoader(File("./lobby1.schem"), WORLD) LOBBY_SCHEMATIC = SchematicLoader(File("./CloudCityTower.schem"), WorldManager.LIMBO_WORLD)
//val schematicSpawn = LOBBY_SCHEMATIC.spawnSchematicAt(0, SPAWN_HEIGHT, 0) val schematicSpawn = LOBBY_SCHEMATIC.spawnSchematicAt(0, SPAWN_HEIGHT, 0)
WorldManager.LIMBO_SPAWN = Location( WorldManager.LIMBO_SPAWN = Location(
WorldManager.LIMBO_WORLD, WorldManager.LIMBO_WORLD,
0.0, 0.0,
@ -177,7 +181,7 @@ class RunnerDragon : JavaPlugin() {
.build() .build()
Bukkit.broadcast(launchComponent) Bukkit.broadcast(launchComponent)
//LOBBY_SCHEMATIC.removeSchematic() LOBBY_SCHEMATIC.removeSchematic()
TIMER_TASK = TimerTask().runTaskTimer(instance, 0L, 20L) TIMER_TASK = TimerTask().runTaskTimer(instance, 0L, 20L)
GRACE_PERIOD_TASK = GracePeriodTask().runTaskTimer(instance, 0L, 20L) GRACE_PERIOD_TASK = GracePeriodTask().runTaskTimer(instance, 0L, 20L)

View file

@ -9,7 +9,6 @@ import org.bukkit.Bukkit
import org.bukkit.entity.Player import org.bukkit.entity.Player
import xyz.ineanto.dragon.RunnerDragon import xyz.ineanto.dragon.RunnerDragon
@Suppress("UnstableApiUsage")
class GameCommand : BasicCommand { class GameCommand : BasicCommand {
override fun execute( override fun execute(
stack: CommandSourceStack, stack: CommandSourceStack,

View file

@ -41,7 +41,6 @@ class FinalBlowListener : Listener {
) )
.build() .build()
val teamComponent = Component.text() val teamComponent = Component.text()
.append(RunnerDragon.PREFIX) .append(RunnerDragon.PREFIX)
.appendSpace() .appendSpace()
@ -53,7 +52,6 @@ class FinalBlowListener : Listener {
) )
.appendSpace() .appendSpace()
teamComponent.appendSpace() teamComponent.appendSpace()
teamComponent.append(Component.text("!", NamedTextColor.WHITE, TextDecoration.BOLD)) teamComponent.append(Component.text("!", NamedTextColor.WHITE, TextDecoration.BOLD))

View file

@ -0,0 +1,47 @@
package xyz.ineanto.dragon.schematic
import com.sk89q.worldedit.EditSession
import com.sk89q.worldedit.WorldEdit
import com.sk89q.worldedit.WorldEditException
import com.sk89q.worldedit.bukkit.BukkitAdapter
import com.sk89q.worldedit.extent.clipboard.Clipboard
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats
import com.sk89q.worldedit.function.operation.Operation
import com.sk89q.worldedit.function.operation.Operations
import com.sk89q.worldedit.math.BlockVector3
import com.sk89q.worldedit.session.ClipboardHolder
import org.bukkit.World
import java.io.File
import java.io.FileInputStream
class SchematicLoader(private val schematic: File, private val world: World) {
private lateinit var session: EditSession
fun spawnSchematicAt(x: Int, y: Int, z: Int): Boolean {
val worldEditWorld = BukkitAdapter.adapt(world)
WorldEdit.getInstance().newEditSession(worldEditWorld).use operation@{ weSession ->
var clipboard: Clipboard
val format = ClipboardFormats.findByFile(schematic)
format!!.getReader(FileInputStream(schematic)).use { reader -> clipboard = reader.read() }
session = weSession
val operation: Operation = ClipboardHolder(clipboard)
.createPaste(weSession)
.to(BlockVector3.at(x, y, z))
.copyEntities(true)
.build()
try {
Operations.complete(operation)
return true
} catch (exception: WorldEditException) {
exception.printStackTrace()
return false
}
}
}
fun removeSchematic() {
session.undo(session)
}
}

View file

@ -22,19 +22,10 @@ class WorldManager(private val instance: RunnerDragon) {
fun init(): Boolean { fun init(): Boolean {
val limboFolder = File(LIMBO_WORLD_NAME) val limboFolder = File(LIMBO_WORLD_NAME)
if (!limboFolder.exists()) { LIMBO_WORLD = createWorld(LIMBO_WORLD_NAME, World.Environment.NORMAL, false)
// Limbo is the world where players are
// held (hostage) before the game starts.
instance.logger.severe("Limbo world doesn't exist! Generating an emergency spawn...")
LIMBO_WORLD = createWorld(LIMBO_WORLD_NAME, World.Environment.NORMAL, false)
} else {
// Load the Limbo world
LIMBO_WORLD = Bukkit.createWorld(WorldCreator(LIMBO_WORLD_NAME))!!
}
LIMBO_SPAWN = LIMBO_WORLD.spawnLocation LIMBO_SPAWN = LIMBO_WORLD.spawnLocation
LIMBO_WORLD.difficulty = Difficulty.PEACEFUL LIMBO_WORLD.difficulty = Difficulty.PEACEFUL
cleanupPreviousWorlds() // cleanupPreviousWorlds()
createGameWorlds() createGameWorlds()
return true return true
} }

View file

@ -2,7 +2,8 @@ name: RunnerDragon
version: '1.1' version: '1.1'
api-version: '1.21' api-version: '1.21'
main: xyz.ineanto.dragon.RunnerDragon main: xyz.ineanto.dragon.RunnerDragon
loader: xyz.ineanto.dragon.RunnerDragonLoader dependencies:
- WorldEdit
commands: commands:
rd: rd: