Skip to content

Commit

Permalink
Add Development Server (#18)
Browse files Browse the repository at this point in the history
* feat: add development server

* fix: kotlin not being shaded

* fix: x/y bounds & automatically op
Automatically grant op/creative on local server
  • Loading branch information
DebitCardz authored Nov 25, 2023
1 parent 30ec36d commit 01deee1
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ out/
/.nb-gradle/

### VS Code ###
.vscode/
.vscode/

### Other ###
development/run
!development/run/eula.txt
!development/run/server.properties
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.9.0"
kotlin("jvm") version "1.9.20"

id("maven-publish")
}
Expand All @@ -18,7 +18,6 @@ repositories {

dependencies {
implementation(kotlin("stdlib"))

compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
}

Expand Down
45 changes: 45 additions & 0 deletions development/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import xyz.jpenilla.runpaper.task.RunServer

plugins {
kotlin("jvm") version "1.9.20"
id("com.github.johnrengelman.shadow") version "8.1.1"

id("net.minecrell.plugin-yml.bukkit") version "0.5.3"
id("xyz.jpenilla.run-paper") version "2.1.0"
}

group = "me.tech"
version = "1.0.0"

repositories {
mavenCentral()

maven("https://papermc.io/repo/repository/maven-public/")
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")

// implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")
implementation(rootProject)
}

tasks.withType<RunServer> {
minecraftVersion("1.20.2")
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

bukkit {
name = "ui-development"
apiVersion = "1.20"
version = "${project.version}"
authors = listOf("Tech")
main = "me.tech.development.DevelopmentPlugin"

commands {
register("openui")
}
}
3 changes: 3 additions & 0 deletions development/run/eula.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
#Sat Nov 25 10:08:58 EST 2023
eula=true
60 changes: 60 additions & 0 deletions development/run/server.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#Minecraft server properties
#Sat Nov 25 10:27:18 EST 2023
enable-jmx-monitoring=false
rcon.port=25575
level-seed=
gamemode=survival
enable-command-block=false
enable-query=false
generator-settings={}
enforce-secure-profile=true
level-name=world
motd=A Minecraft Server
query.port=25565
pvp=true
generate-structures=true
max-chained-neighbor-updates=1000000
difficulty=easy
network-compression-threshold=256
max-tick-time=60000
require-resource-pack=false
use-native-transport=true
max-players=20
online-mode=true
enable-status=true
allow-flight=false
initial-disabled-packs=
broadcast-rcon-to-ops=true
view-distance=2
server-ip=
resource-pack-prompt=
allow-nether=true
server-port=25565
enable-rcon=false
sync-chunk-writes=true
op-permission-level=4
prevent-proxy-connections=false
hide-online-players=false
resource-pack=
entity-broadcast-range-percentage=100
simulation-distance=10
rcon.password=
player-idle-timeout=0
debug=false
force-gamemode=false
rate-limit=0
hardcore=false
white-list=false
broadcast-console-to-ops=true
spawn-npcs=true
spawn-animals=true
log-ips=true
function-permission-level=2
initial-enabled-packs=vanilla
level-type=minecraft\:normal
text-filtering-config=
spawn-monsters=true
enforce-whitelist=false
spawn-protection=16
resource-pack-sha1=
max-world-size=29999984
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package me.tech.development

import me.tech.mcchestui.*
import net.kyori.adventure.text.Component
import org.bukkit.GameMode
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.plugin.java.JavaPlugin

class DevelopmentPlugin : JavaPlugin(), Listener {
override fun onEnable() {
getCommand("openui")?.setExecutor { sender, _, _, _ ->
(sender as? Player)?.openGUI(open(sender))
true
}

// op & set gamemode on local server.
server.pluginManager.registerEvents(object : Listener {
@EventHandler
fun PlayerJoinEvent.on() {
player.gameMode = GameMode.CREATIVE
player.isOp = true
}
}, this)
}

private fun open(player: Player): GUI {
return gui(
this,
title = Component.text("Test UI"),
type = GUIType.Chest(rows = 3)
) {
slot(1, 1) {
item = item(Material.CAKE)
onClick = { it.sendMessage("You've clicked the cake!") }
}
}
}
}
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
rootProject.name = "mc-chestui-plus"
rootProject.name = "mc-chestui-plus"

include("development")

0 comments on commit 01deee1

Please sign in to comment.