Remove legacy modules, add language & scoreboard
Large refactor removing many legacy subsystems (abilities, kit system, database repos, recraft, world manager, extensive config classes, lunar/luckperms integrations and various listeners/commands). Introduces a lightweight LanguageManager, AntiRunningManager, ScoreboardManager, ConnectListener and a SoupListener; simplifies the main SpeedHG plugin to initialize these components and register the connection listener. Build changes: update Gradle wrapper to 8.10, remove paperweight and several external dependencies, add fr.mrmicky:fastboard and simplify shadowJar/build task configuration. Adds default language resource (languages/en_US.yml) and updates plugin/config resources. Purpose: simplify and decouple the plugin, reduce dependency surface and prepare for a leaner, modular rewrite.
This commit is contained in:
@@ -1,159 +0,0 @@
|
||||
package club.mcscrims.speedhg.world
|
||||
|
||||
import club.mcscrims.speedhg.SpeedHG
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.GameRule
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.World
|
||||
import org.popcraft.chunky.api.ChunkyAPI
|
||||
import java.io.File
|
||||
|
||||
class WorldManager(
|
||||
private val plugin: SpeedHG
|
||||
) {
|
||||
|
||||
private var worldName = "world"
|
||||
private lateinit var world: World
|
||||
|
||||
fun highestLocationWithRadius(
|
||||
center: Location,
|
||||
radius: Int
|
||||
): Location
|
||||
{
|
||||
getWorld()
|
||||
val minX = center.blockX - radius
|
||||
val minZ = center.blockZ - radius
|
||||
val maxX = center.blockX + radius
|
||||
val maxZ = center.blockZ + radius
|
||||
|
||||
var highestY = center.blockY
|
||||
var highestX = minX
|
||||
var highestZ = minZ
|
||||
|
||||
for ( x in minX..maxX )
|
||||
for ( z in minZ..maxZ )
|
||||
{
|
||||
val y = world.getHighestBlockYAt( x, z )
|
||||
|
||||
if ( y > highestY )
|
||||
{
|
||||
highestY = y
|
||||
highestX = x
|
||||
highestZ = z
|
||||
}
|
||||
}
|
||||
|
||||
val highest = Location( world, highestX.toDouble(), highestY.toDouble(), highestZ.toDouble() )
|
||||
return highest
|
||||
}
|
||||
|
||||
/*
|
||||
* DELETION >>
|
||||
*/
|
||||
|
||||
fun deleteWorld()
|
||||
{
|
||||
getWorld()
|
||||
Bukkit.unloadWorld( worldName, false )
|
||||
val folder = File( worldName )
|
||||
deleteFolder( folder )
|
||||
}
|
||||
|
||||
private fun deleteFolder(
|
||||
folder: File
|
||||
) {
|
||||
val files = folder.listFiles()
|
||||
|
||||
if ( files != null )
|
||||
for ( f in files )
|
||||
{
|
||||
if ( f.isDirectory )
|
||||
deleteFolder( f )
|
||||
else
|
||||
f.delete()
|
||||
}
|
||||
|
||||
folder.delete()
|
||||
}
|
||||
|
||||
/*
|
||||
* WORLD >>
|
||||
*/
|
||||
|
||||
lateinit var spawnLocation: Location
|
||||
var borderDecrease: Double = 100.0
|
||||
|
||||
fun setupWorld()
|
||||
{
|
||||
val world = getWorld() ?: return
|
||||
plugin.logger.info("Setting up world...")
|
||||
|
||||
// BORDER >>
|
||||
|
||||
plugin.logger.info("Setting up world... [STAGE [1]: WORLDBORDER]")
|
||||
|
||||
spawnLocation = Location( world, 0.0, world.getHighestBlockYAt( 0, 0).toDouble(), 0.0 )
|
||||
world.worldBorder.center = spawnLocation
|
||||
|
||||
world.worldBorder.size = plugin.pluginConfig.data.world.border["size"]!!
|
||||
world.worldBorder.warningDistance = plugin.pluginConfig.data.world.border["warning_distance"]!!.toInt()
|
||||
world.worldBorder.damageAmount = plugin.pluginConfig.data.world.border["damage"]!!
|
||||
|
||||
borderDecrease = plugin.pluginConfig.data.world.border["decrease"]!!
|
||||
|
||||
// GAMERULES >>
|
||||
|
||||
plugin.logger.info("Setting up world... [Stage [2]: GAMERULES]")
|
||||
|
||||
world.setGameRule( GameRule.ANNOUNCE_ADVANCEMENTS, false )
|
||||
world.setGameRule( GameRule.DO_INSOMNIA, false )
|
||||
world.setGameRule( GameRule.DISABLE_RAIDS, true )
|
||||
world.setGameRule( GameRule.DO_PATROL_SPAWNING, false )
|
||||
world.setGameRule( GameRule.DO_TRADER_SPAWNING, false )
|
||||
|
||||
// CHUNKY >>
|
||||
|
||||
// plugin.logger.info("Setting up world... [Stage [3]: CHUNKY]")
|
||||
// val chunky = Bukkit.getServicesManager().load( ChunkyAPI::class.java )
|
||||
//
|
||||
// if ( chunky == null || chunky.version() != 0 )
|
||||
// {
|
||||
// plugin.isReady = true
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// val radius = world.worldBorder.size / 2
|
||||
//
|
||||
// chunky.startTask( worldName, "square", 0.0, 0.0, radius, radius, "concentric" )
|
||||
// chunky.onGenerationComplete { plugin.isReady = true }
|
||||
//
|
||||
// plugin.server.dispatchCommand( Bukkit.getConsoleSender(), "chunky silent" )
|
||||
|
||||
// FINISH >>
|
||||
|
||||
plugin.logger.info("World has been set up!")
|
||||
}
|
||||
|
||||
private fun setWorld(
|
||||
worldName: String
|
||||
): World?
|
||||
{
|
||||
this.worldName = worldName
|
||||
val world = Bukkit.getWorld( worldName )
|
||||
|
||||
if ( world != null )
|
||||
this.world = world
|
||||
|
||||
return world
|
||||
}
|
||||
|
||||
fun getWorld(): World?
|
||||
{
|
||||
return if ( !::world.isInitialized )
|
||||
try {
|
||||
setWorld( plugin.pluginConfig.data.world.name )
|
||||
} catch ( _: Exception ) { null }
|
||||
else this.world
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user