feat: convert to spigot plugin
This commit is contained in:
parent
7665ef9114
commit
cad059a376
9 changed files with 72 additions and 25 deletions
5
TODO.md
5
TODO.md
|
@ -1,5 +1,4 @@
|
|||
- [ ] 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
|
||||
- [ ] spread le spawn dans un rayon de 1000 blocks
|
||||
|
@ -11,4 +10,8 @@ balancer les coordonnées
|
|||
```kotlin
|
||||
val advancement = Advancement.Builder.advancement().save({}, "runnerdragon:test").toBukkit()
|
||||
Player.getAdvancementProgress(advancement)
|
||||
|
||||
// Localiser les structures proches
|
||||
val locateNearestStructure =
|
||||
player.world.locateNearestStructure(player.location, StructureType.STRONGHOLD, 300, false)
|
||||
```
|
|
@ -20,12 +20,12 @@ dependencies {
|
|||
paperweight.paperDevBundle("1.21.8-R0.1-SNAPSHOT")
|
||||
|
||||
// Inventory UI
|
||||
compileOnly(libs.invui)
|
||||
compileOnly(libs.invui.kotlin)
|
||||
implementation(libs.invui)
|
||||
implementation(libs.invui.kotlin)
|
||||
|
||||
// Resource Pack (unused)
|
||||
implementation(libs.glyphs.api)
|
||||
implementation(libs.glyphs.resources)
|
||||
// WorldEdit
|
||||
compileOnly("com.sk89q.worldedit:worldedit-core:7.3.16-SNAPSHOT")
|
||||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.16-SNAPSHOT")
|
||||
|
||||
implementation(libs.kotlin.stdlib)
|
||||
implementation(libs.commonsio)
|
||||
|
@ -46,5 +46,9 @@ tasks {
|
|||
|
||||
runServer {
|
||||
minecraftVersion("1.21.8")
|
||||
|
||||
downloadPlugins {
|
||||
url("https://cdn.modrinth.com/data/1u6JkXh5/versions/Jk1z2u7n/worldedit-bukkit-7.3.16.jar")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import xyz.ineanto.dragon.event.end.BlockPlaceListener
|
|||
import xyz.ineanto.dragon.event.end.FinalBlowListener
|
||||
import xyz.ineanto.dragon.event.waiting.WaitingListener
|
||||
import xyz.ineanto.dragon.player.PlayerManager
|
||||
import xyz.ineanto.dragon.schematic.SchematicLoader
|
||||
import xyz.ineanto.dragon.scoreboard.ScoreboardTeams
|
||||
import xyz.ineanto.dragon.tasks.GracePeriodTask
|
||||
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.world.WorldManager
|
||||
import xyz.xenondevs.invui.InvUI
|
||||
import java.io.File
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
|
@ -58,11 +60,13 @@ class RunnerDragon : JavaPlugin() {
|
|||
var DEAD_COWS = 0
|
||||
var ELAPSED_TIME = 0
|
||||
|
||||
var SPAWN_HEIGHT = 300
|
||||
var SPAWN_HEIGHT = 150
|
||||
var TEAM_LOCK = false
|
||||
var NETHER_PORTAL_ENTERED = false
|
||||
var END_PORTAL_ENTERED = false
|
||||
|
||||
lateinit var LOBBY_SCHEMATIC: SchematicLoader
|
||||
|
||||
//.............
|
||||
// TASKS
|
||||
//.............
|
||||
|
@ -129,8 +133,8 @@ class RunnerDragon : JavaPlugin() {
|
|||
DEAD_COWS = 0
|
||||
|
||||
logger.info("Génération du spawn...")
|
||||
//LOBBY_SCHEMATIC = SchematicLoader(File("./lobby1.schem"), WORLD)
|
||||
//val schematicSpawn = LOBBY_SCHEMATIC.spawnSchematicAt(0, SPAWN_HEIGHT, 0)
|
||||
LOBBY_SCHEMATIC = SchematicLoader(File("./CloudCityTower.schem"), WorldManager.LIMBO_WORLD)
|
||||
val schematicSpawn = LOBBY_SCHEMATIC.spawnSchematicAt(0, SPAWN_HEIGHT, 0)
|
||||
WorldManager.LIMBO_SPAWN = Location(
|
||||
WorldManager.LIMBO_WORLD,
|
||||
0.0,
|
||||
|
@ -177,7 +181,7 @@ class RunnerDragon : JavaPlugin() {
|
|||
.build()
|
||||
|
||||
Bukkit.broadcast(launchComponent)
|
||||
//LOBBY_SCHEMATIC.removeSchematic()
|
||||
LOBBY_SCHEMATIC.removeSchematic()
|
||||
|
||||
TIMER_TASK = TimerTask().runTaskTimer(instance, 0L, 20L)
|
||||
GRACE_PERIOD_TASK = GracePeriodTask().runTaskTimer(instance, 0L, 20L)
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.bukkit.Bukkit
|
|||
import org.bukkit.entity.Player
|
||||
import xyz.ineanto.dragon.RunnerDragon
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
class GameCommand : BasicCommand {
|
||||
override fun execute(
|
||||
stack: CommandSourceStack,
|
||||
|
|
|
@ -41,7 +41,6 @@ class FinalBlowListener : Listener {
|
|||
)
|
||||
.build()
|
||||
|
||||
|
||||
val teamComponent = Component.text()
|
||||
.append(RunnerDragon.PREFIX)
|
||||
.appendSpace()
|
||||
|
@ -53,7 +52,6 @@ class FinalBlowListener : Listener {
|
|||
)
|
||||
.appendSpace()
|
||||
|
||||
|
||||
teamComponent.appendSpace()
|
||||
teamComponent.append(Component.text("!", NamedTextColor.WHITE, TextDecoration.BOLD))
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -22,19 +22,10 @@ class WorldManager(private val instance: RunnerDragon) {
|
|||
fun init(): Boolean {
|
||||
val limboFolder = File(LIMBO_WORLD_NAME)
|
||||
|
||||
if (!limboFolder.exists()) {
|
||||
// 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_WORLD.difficulty = Difficulty.PEACEFUL
|
||||
cleanupPreviousWorlds()
|
||||
// cleanupPreviousWorlds()
|
||||
createGameWorlds()
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ name: RunnerDragon
|
|||
version: '1.1'
|
||||
api-version: '1.21'
|
||||
main: xyz.ineanto.dragon.RunnerDragon
|
||||
loader: xyz.ineanto.dragon.RunnerDragonLoader
|
||||
dependencies:
|
||||
- WorldEdit
|
||||
|
||||
commands:
|
||||
rd:
|
Loading…
Add table
Add a link
Reference in a new issue